|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-14 09:29 UTC] dave at netready dot biz
There is an error with the parsing of the PHP start tag "<?PHP"... Turn on all error reporting... error_reporting( E_ALL ); This works ok <?PHP /*Hello*/?> However without the space it outputs a warning: "Warning: Use of undefined constant PHP - assumed 'PHP'" <?PHP/*Hello*/?> But this (correctly) doesn't output anything... <?/*Hello*/?> If you put code after the comment it is worse. <?PHP/*Hello*/ print "Hello"; ?> This actually dies with a "parser error", but again this works if you use the shorter tag. <?/*Hello*/ print "Hello"; ?> Outputs "Hello" as expected. The fact that it works when you use "<?" instead of "<?PHP" is what leads me to believe this is a bug and not just a feature of the language. Surely they should both behave the same? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 23:00:01 2025 UTC |
How about a decent warning/error when you miss the space then?... At the moment you either get (with all warnings on) "Warning: Use of undefined constant PHP - assumed 'PHP' or it's dies with a "parser error" at line whatever, depending what you have put after the <?PHP token. As a programmer I am quite curious to know how the start token has been implemented, it is obviously a lot more complicated than it looks...I thought it would be (sudo-code :) if token="<?" or token="<%" or token="<?PHP" then start_php else don't. end if (...hmmm actually that's VB, not sudo code! - my deepest apologies) but judging from the behaviour it would seem that it looks for "<?" or "<%" and then if there is a "PHP " it simply ignores it? whereas "PHP" (without the space) doesn't match so it thinks its a constant. Or is this all to do with delimiting characters? obviously with something like <?PHPprint"Hello";?> the scanner would not find a delimiter so I assume you'd end up with a token "PHPprint" ? which the parser doesn't understand. I digress... an error message is all I ask.