My Apache/PHP installation is making me use <?php ... ?> instead of <? ... ?>. Where is this found in the configuration file so that I don't need to do the former? I'm assuming it's in php.ini, but not sure what it would be called.
4 Answers
2 Comments
John Smith
Thanks, and yes I understand the portability thing - but I just redid my server and have tons of old stuff with those style tags. But going forward - good idea :)
Ben Rowe
In that case it may be better to use a .htaccess file and set the short_open_tag for your legacy code, but keep your server correctly configured to ensure maximum portability for your code.
It is defined in php.ini as short_open_tag.
Keep in mind however, for maximum portability, stick with <?php ... ?>. You have just proved to yourself how unreliable it is to rely on short tags being enabled. You wouldn't want to show the world your PHP source if it made its way onto a short tag disabled server would you?
I've also read, but can not confirm, that short tags will be removed in newer versions of PHP.
<?short open tag is not valid in XML or XHTML, so it breaks some developer tools that test for valid web page markup. Because of this, lots of people consider it better practice to continue using the<?phplonger open tag.<?=$variable;?>and clean and simple syntax like stackoverflow.com/questions/2795847/… are a big plus.