Support the ongoing development of Laravel.io →
Input Views Blade

Hi:

I have this view:

$post->user->name

I can call it in the post page successfully

Now i need to assign that value into the main template template into a new var, but it doesn't work.

Something like this:

<?php
				$metaAuthorName = "($post->user->name)";
?>

How can i pass this value to the new var? Thank you

Last updated 3 years ago.
0

You need to do like this

<?php
                $metaAuthorName = $post->user->name;
?>

If you do with " " , you will save "($post->user->name)" in $metaAuthorName, but if you do $metaAuthorName = $post->user->name you will save the value of $post->user->name into $metaAuthorName

0

dormidosan said:

You need to do like this

<?php
               $metaAuthorName = $post->user->name;
?>

If you do with " " , you will save "($post->user->name)" in $metaAuthorName, but if you do $metaAuthorName = $post->user->name you will save the value of $post->user->name into $metaAuthorName

Thanks , this work perfect.

Last updated 9 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Medow medow Joined 25 Sep 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.