StormTheGates Posted August 7, 2010 Share Posted August 7, 2010 Hey all, I have an odd problem that I hope someone here has had and knows how to fix. I recently installed Apache, PHP, and MySQL on a new server we have at work. Everything works fine, oddly enough, except for PHP parsing. You see the following code: <? echo "test"; ?> Will display the PHP code, while <?php echo "test"; ?> Will echo "test". The problem seems to be that PHP isnt parsing the <? directive as a start command. Does anyone have any idea why this might be? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/ Share on other sites More sharing options...
Ruzzas Posted August 7, 2010 Share Posted August 7, 2010 I believe its a certain setting in PHP. I haven't any clue which one though. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096319 Share on other sites More sharing options...
Ruzzas Posted August 7, 2010 Share Posted August 7, 2010 whoops, found it: short_open_tag http://php.net/manual/en/ini.core.php Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096321 Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 Always use full PHP (tag) syntax, that way issues like this will never arise. Tags such as <? ?> or <?= ?> will only be available when a setting called short_open_tag is enabled. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096322 Share on other sites More sharing options...
PFMaBiSmAd Posted August 7, 2010 Share Posted August 7, 2010 Don't use the short open tags. It results in non-portable code because you won't always be on a server where you will have the ability to turn the setting on. You have probably already wasted 10x times more time messing with this on one server setup than you ever saved in typing time by leaving off three letters a few times on a page. If you simply use full opening tags, you won't ever need to waste any of your time messing with this problem when you put your code onto a different server. And if you ever expect to publish any of your code for others to use, you CANNOT use short open tags in it because the people using that code won't necessarily have the ability to turn on the setting on their server. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096323 Share on other sites More sharing options...
StormTheGates Posted August 7, 2010 Author Share Posted August 7, 2010 whoops, found it: short_open_tag http://php.net/manual/en/ini.core.php You are both a gentleman and a scholar. Fixed it right up, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096327 Share on other sites More sharing options...
StormTheGates Posted August 7, 2010 Author Share Posted August 7, 2010 Don't use the short open tags. It results in non-portable code because you won't always be on a server where you will have the ability to turn the setting on. You have probably already wasted 10x times more time messing with this on one server setup than you ever saved in typing time by leaving off three letters a few times on a page. If you simply use full opening tags, you won't ever need to waste any of your time messing with this problem when you put your code onto a different server. And if you ever expect to publish any of your code for others to use, you CANNOT use short open tags in it because the people using that code won't necessarily have the ability to turn on the setting on their server. Relax boss, I didnt exactly get a choice. The government hands me the code, I just make it run on our servers. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096329 Share on other sites More sharing options...
PFMaBiSmAd Posted August 7, 2010 Share Posted August 7, 2010 Ummm. You can search and replace the tags to fix the problem forever in any piece of code. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096331 Share on other sites More sharing options...
StormTheGates Posted August 7, 2010 Author Share Posted August 7, 2010 Ummm. You can search and replace the tags to fix the problem forever in any piece of code. You assume that the government wants things functional and backwards compatible. The last time I mucked with their code they had a hissy fit. Trust me I know <? are bad tags, Ive seen benchmarks where the <?php is much faster. But sadly they are paying the bills so I just make our server run it. Quote Link to comment https://forums.phpfreaks.com/topic/210071-php-wont-parse/#findComment-1096334 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.