Jump to content

PHP Variables


shadowayex

Recommended Posts

I was wondering if there was a way I could print PHP Variables in the middle of HTML without opening PHP ( <?php ). For example, I have a variable that stores the username of a user and is used to greet the user on the pages. Is there a way I can have it written without typing it like this:Hello <?php echo $user ?>!

Link to comment
Share on other sites

There is HEREDOC syntax if you want to write large strings with variables without having to worry about escaping.

echo <<<EOTYour long string can go here.This is $foo['bar'] and {$foo->bar}.EOT;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...