Page 1 of 1

<?php header oddity with PHP5 on windows server.

Posted: Fri Sep 02, 2005 11:43 am
by xenon2000
I had been using Windows XP with Apache 1.3.x and PHP 4.3.x and MYSQL 4.1.x for a long time. This is my dev PC, eventually hosted on a Linux webserver. I recent started working on an app that deals with birthdays and was testing for dates pre-1970 and some other date formattings. Found that PHP 4.x on windows and some linux boxes has an issue with pre Unix Epoc dates. So I saw that PHP5.1RC1 fixed that for the windows platform.

So I decided to update my Apache and PHP to Apache 2.0.54 and PHP 5.1.0 RC1. Leaving MYSQL at 4.1.7. Everything works now with the new Apache and PHP5.... but now there is an oddity for php scripts.

Before I have always been able to start a php script with just <? instead of <?php, not the best habit I guess. But since my php files always are named something.php and I don't mix inline code, I don't see a reason to always state <?php everytime I break in and out of php in a php file. Anyways, that has always worked fine. Until now.

Now in PHP5.1RC1 on windows, if I start with <?php in the sript, then it works fine. But if I just start with <? then my PHP code displays instead of being executed. I guess it could be an apache issue, but it seems that since apache is only looking at the file name extension to determine what will parse it, then it should mean that it's php that is reading the <? and deciding not to execute the code.

So I am wondering, is the a setting for php.ini to control this for PHP5.1? I am hoping this thread does not turn into an argument about <?php vs <? for a something.php file. Hopefully someone else has seen this issue too. And does anyone have a Linux PHP5.1RC1 Apache 2.0.x setup that they could test this oddity on? I am curious if it's just a windows php5 issue or all platforms. Or just a php.ini setting that can be altered to work like my default php4.3.x setup. Thanks again.

Posted: Fri Sep 02, 2005 11:46 am
by feyd
short tags are off.


Moved to Web Servers.

Posted: Fri Sep 02, 2005 11:47 am
by nielsene
As feyd says, check the "short_open_tag" option in php.ini.

Posted: Fri Sep 02, 2005 12:02 pm
by xenon2000
feyd wrote:short tags are off.


Moved to Web Servers.
Thanks for the suggestion. That worked. Short tags were Off, changed it to On and there we go. I have seen that before, but did not know it also included the <?php header. Oh well. Good to know. I also see the comment in the php.ini about why not to use the On setting, so I will just make a habbit of using <?php instead. Even though I haven't been doing so for a long time. No big deal though, nice to know though.

I don't remember ever setting any of my php4 setups with Short Tags = On, so odd that the default is now Off.

Thanks again. Odd that I couldn't find this little note in all my searching. Then I could have saved the embarrasing post about such a simple php.ini setting. Thanks though.

Posted: Fri Sep 02, 2005 12:09 pm
by feyd
heheh.. it's be defaulted to On up until really recently. So no worries, but yes, it is best practice to use <?php over <?. :)

Posted: Fri Sep 02, 2005 12:25 pm
by xenon2000
feyd wrote:heheh.. it's be defaulted to On up until really recently. So no worries, but yes, it is best practice to use <?php over <?. :)
Thank goodness for search and replace. Now ALL my code has been converted from <? to <?php

I noticed in all my code, that I had already started all my scripts with <?php, but that all the other breaks in and out of php were just <?. But now they are all <?php, so that was easy enough.