Hi there, my host won't turn on short tags and I have a script that has some in it so it won't work. My question is what do I change this to?: <?= Do I just use <?php or is it <?php echo, or? Thanks for your help!
With PHP 5.4 short tags are accepted regardless of php.ini settings. Read more here: http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use
Good lord why the **** would they do that? (NOT A FAN of the needlessly cryptic) Can you find proof of that on a php.net since I'm not finding it.... Oh wait, I see it... Ok, that's KIND-OF true. In PHP 5.4 <?= is always available, but <? still obeys shorttags being off... Lemme test... Yup, that's how it works. Though again, if I had by way all of those would be stricken from PHP entirely.
There's a reason for it, and it's also why the use of shorttags is discouraged and disabled by default. <? conflicts with outputting XML. (though I get around that by never outputting code anyplace but with ECHO, since you can <?php ?> inside a string all you want and it won't trip!) With shorttags on, this: <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Dumbass</to> <from>Red</from> <heading>Reminder</heading> <body>Don't be a dumbass</body> </note> Code (markup): In a .php file would fail to output the XML header, and instead try to parse that XML declaration as PHP! That's why shorttags is off by default. Apparently <?= doesn't trip this bug (for obvious reasons, that one extra character). A doctype can cause similar issues. To get around this problem, you either need to turn off shorttags, or echo it out. Even with shorttags on, even in older versions of PHP, this would never have that problem: <?php echo '<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Dumbass</to> <from>Red</from> <heading>Reminder</heading> <body>Don't be a dumbass</body> </note>'; Code (markup): But again that's another reason I'm in favor of <?php and ?> being stricken from the language entirely. Either that or have a new file extension as a trigger to say "ALL of this is PHP, ignore PHP start/end tags"