Hello everybody.. I've read about the "heredoc" way of outputting strings..
Where can we consider this use handy??
Is it used only to avoid escaping the single and double quotation mark??
Also, why is there an identifier to be put at the first and end of the function??
Heredoc syntax is a way to use custom identifier to delimit strings in PHP. Usualy string are delimited with single or double quotes, but with heredoc you declare (name) an identifier. This way you do not have to escape single and double quotes anymore. Te rules for chosing identifier name are same as for other labels in PHP. You put identifier in the beginning (after <<<) to let PHP know that now this is the delimiter for the string and you put at the end to let PHP know where the end of the string is. The line with closing identifier shall not contain any other characters (even no indent) which could be the only drawback since it might spoil the look of your code :-).
Thank you.. However, as I mentioned, I've read a lot about it, and I know what it is, but I wanted to know is it only handy when we want to avoid escaping the single and double quotes?? In addition, I want to know why is there an identifier?? I mean why isn't there a specific identifier to put always?? Why isn't this way used, for example, as the following always:
$MyVariable = <<< E
Here goes the value of the variable......
without changing the letter "E" (or any other letter specified by PHP parser) whatever we are writing???