Edit report at https://bugs.php.net/bug.php?id=16066&edit=1
ID: 16066 Updated by: ras...@php.net Reported by: dave at netready dot biz Summary: <?PHP tag warning! Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux (Debian) PHP Version: 4.1.1 Block user comment: N Private report: N New Comment: Sorry, as per the XML spec, a PI tag, which is what PHP uses, is <? PHP<whitespace> It simply isn't valid starting tag without the whitespace. Something else could easily come along that uses <?p or perhaps <?ph or even <?phpe as the processing instruction name. Nothing can start processing these tags until a valid one is found. Previous Comments: ------------------------------------------------------------------------ [2012-12-27 04:43:56] MTee7 at LightHouse57 dot com This little item bit me in the ass lately. I was in the habit of using just <? in my scripts. Then my server upgraded to 5.3, but they didn't have the 'short tag' flag set...supposedly a security risk? At any rate now my scripts all died. SO I did a global replace of <? with <?php to solve the problem. BUT, there were many places in the code where <? had no spaces after it. So now there were parts of code that also had no spaces, and it didn't like that at all. I agree that <?echo 'Hey beautiful' looks better than <?phpecho 'Hey Beautiful'........but code is not supposed to 'look good'......it's supposed to be CONSISTENT. So imo if <? starts php code...in that it parses the next character after the ?....well then it should ALSO parse the first character after ?php There......another few blows to the apparently dead horse..... And puleeeeeze....no comments about the age of this post....Google brought it to my attention.......and Google apparently thinks it has value....and just because a post is old doesn't mean it has lost it's value to others......so THERE.......z ------------------------------------------------------------------------ [2002-03-18 07:05:22] dave at netready dot biz 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. ------------------------------------------------------------------------ [2002-03-18 06:26:24] g...@php.net <?php is XML compliant, and in XML you need to put a spacw there. While <? is a shortcut, and as usual, people would like to use it in the short way, with no space after it, like <?=SID?> Goba ------------------------------------------------------------------------ [2002-03-18 04:07:26] dave at netready dot biz I totally agree that you <?phpprint_r($GLOBALS)?> is horrible. The reason I found this problem was that I was commenting out a section of HTML using PHP tags. I just stuck in <?PHP/* and */?> but it confused me when it didn't work. If this space is a requirement it really should be mentioned somewhere in the documentation. I'm going to stick a comment on the "Basic Syntax" section of the manual, where it talks about these tags. I do still think they should all be consistant though. ;o) ------------------------------------------------------------------------ [2002-03-15 21:06:49] yohg...@php.net Apperently, short tag does not need spaces after open tag :) However, there is nothing wrong and there is nothing we should fix here. i.e. Changing "<?php" open tag without following spaces is not good idea at all. I'm sure you agree following code is ugly. <?phpprint_r($GLOBALS)?> while <?print_r($GLOBALS)?> is not. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=16066 -- Edit this bug report at https://bugs.php.net/bug.php?id=16066&edit=1