<<EOT PHP

What is <<EOT and what are the advantages/usage of it in php ?
LVL 1
sahanzAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
check out the HEREDOC syntax of php:
http://php.net/manual/en/language.types.string.php
0
 
Ray PaseurConnect With a Mentor Commented:
Example:

$money = 100.00;
$thing = <<<ENDTHING
In here you can put anything you want - lots of lines of HTML, for example.
You can substitute values, for example, $money
ENDTHING;

echo $thing;
0
 
innotionentConnect With a Mentor Commented:
http://onlamp.com/pub/a/php/2003/04/10/php_heredocs.html

here is a decent explanation.
I don't use it myself. However apparently it's an easier way to mix alll your code together.
0
 
Ray PaseurConnect With a Mentor Commented:
Although I have not verified it, this looks like an interesting note.
http://www.php.net/manual/en/language.types.string.php#86365

I find it incredibly useful when you want to separate your code and data from your presentation layer.  You create the values for all your variables, like the $money var in the post at ID:34136208, then you echo a HEREDOC string with the embedded variable names.  In some cases, your HEREDOC string can be the HTML of the entire web page.  Very  nice encapsulation!
0
 
sahanzAuthor Commented:
Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.