Forum Moderators: coopster
1. {$braces} for outputting vars
I use this all the time now, instead of ever concatenating a string
$string1 = "text here {$var} without need for ".$xyz." concatenating"; 2. (triple arrow) <<<
Whenever I'm outputting a string with more than 40-50 chars I always use
$output = <<<HTML
<h1>Header 1</h1>
<p>Paragraph1 - {$var1} etc</p>
HTML; My worry is that I'm coding using something similar to 'short tags' and in future/previous PHP versions these may not work. Any thoughts?
As far as backwards-compatibility -- IMHO if you are not running a PHP5 system today you are really putting yourself in a compromising position. Support for PHP 4 has been discontinued since 2007-12-31.
1. {$braces} for outputting varsI use this all the time now, instead of ever concatenating a string
Just to clarify... it's not strictly the curly braces that allow you to output vars directly in a string, it's the fact you've enclosed the string in double quotes, or used heredoc (<<<) syntax. However, the curly braces are sometimes required in order to avoid ambiguity (PHP Manual: variable parsing [uk2.php.net]). In the examples you've given, the curly braces are optional.
The curly braces (complex syntax) and heredoc syntax were introduced in PHP 4 - so yes, it's backwards compatible. But, as coopster suggests, that shouldn't be an issue for new scripts.