What is the difference between EOT and HTML? in PHP

What is the difference between EOT and HTML? in PHP

Nothing, its just a delimiter for the HEREDOC syntax. The only benefit of using HEREDOC is you can keep indents and structure of your string in the source code. It tends to be nicer to work with than concatenated strings – for your example Hi <br>, there is no good reason to use HEREDOC.

why would not they use the normal echo?

Using heredoc for this very example makes no sense.
And its indeed to use echo to print out single text line.
So, nobody is using heredoc for this.

Also, in echoing large text blocks heredoc is useless again, as one have to just close PHP tag and write the text as is.

The only use of heredoc is when you need to store a large block of text in a variable.

$var = <<< HERE
Hello %s!
Please follow this link %s to continue registration.
HERE;

What is the difference between EOT and HTML? in PHP

May be very very very late to comment but, in context of todays IDEs: When you use HEREDOCS the identifiers provide a hint as to what kind of information is being stored

Say <<<SQL the IDEs syntax highlighter may use the SQL identifier for highlighting the contents of the string as an SQL Query. <<<HTML for HTML highlighting … and so forth.

Leave a Reply

Your email address will not be published.