Code requires <?php to process
I've installed Apache 2.2 with PHP 5. On other machines, with these same versions, I've always been able to put PHP code in my web files with <? and ?>. With this installation, however, for some reason any code between <? and ?> fails to be executed by the PHP module. Only code between <?php and ?> is executed.
Why would this be, and how can I configure it so it will do as I expected?
This thread and it's predecessor have been rather lonely, since I keep answering my own question before anyone has a chance to respond!
I found this directive in php.ini:
This is what was disabling the use of <? So naturally I turned it on, and finally everything worked.
short_open_tag = Off
It's possible I used php.ini-recommended with this installation but used php.ini-dist in the past. php.ini-dist has this turned on by default.
On this topic, what are the other important differences between the two ini files?
As far as using the short_open_tag option, this has had its default set to OFF for quite a few releases now for a reason: it conflicts with the <?xml tag. Also, as you have found out, depending on it makes your scripts less portable as they become dependent on that PHP setting be set to a non-default value. If you always use the long <?php tag, you can then carry on without ever worrying about that configuration setting.
With regard to other settings, the biggest "gotcha" is old-fashioned scripts which depend upon register_globals being turned on. See http://www.php.net/register_globals for more info on what it does and why the default was changed to OFF.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)