php
Possible PHP Parser
Error
Perplexing PHP Parser Ponderance
Is this an error in the parser or just a feature of the language?
// what will this print out in php5?
$earth = 'World';
$string1 = "Hello ".
$string2 = $earth.'!';
$string = $string1.$string2;
echo $string."n";
// did you catch it, or did you run it to find out?
// here it is again in slow motion:
// note that this fooling of the parsing error
// is quickly given away by showing E_NOTICE..
error_reporting(E_ALL);
// begin with a variable
$earth = 'World';
// now create the first line of
// multi-line concatenation
$string1 = "Hello ".
// now add in the single exclamation
$string2 = $earth.'!'; // $string2 is now equal to World!
// now concatenate "Hello " to "World!"
$string = $string1.$string2;
echo 'string1: '.$string1."n"; //string1: Hello World!
echo 'string2: '.$string2."n"; //string2: World!
echo 'string: '.$string."n"; //string: Hello World!World!
// is this an error in the parser?
// feature-not-bug?
// internal assignment nonsense?
Last Updated: 2011-06-09 22:43:29