Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have Windows 2008 Server with IIS, PHP, MySQL installed on it and there are several PHP websites working fine. But when I try to open one of my websites in a browser it shows the source code of page instead of executing the PHP code.

I thought that this is related to the MySQL database connection at first, but when I installed Vs.Php for Visual Studio 2010 and tried to open my website, it worked.

I think it may be related with IIS settings. By the way test.php works fine.

Any idea?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I had the same problem with some of my sites on my Debian Squeeze server after I upgraded to a newer version of PHP.

The problem was that the PHP pages that weren't loading were using the PHP short form <? ?> and I didn't have short_open_tag enabled in my php.ini file.

If the short_open_tag isn't enabled, one must use <?php instead.

Solutions:

  1. Enable the short_open_tag option in your php.ini file. More on that can be found HERE.
  2. Use the <?php open tag instead of <?. If using XML in conjunction with PHP, this is the best solution, as PHP short tags conflict with XML.
share|improve this answer
    
There is a setting in the php.ini file called short_open_tag that deals specifically with this. [read about it here](php.net/manual/en/ini.core.php) –  nojak Jul 29 '12 at 21:13
    
Thanks Nojak for correcting my half-answer. –  Marcus Sjodin Jul 30 '12 at 9:06
    
woow, thanks man, it worked. I've been dealing with this for 2 days. Thanks a lot Marcus. –  Salim Jul 30 '12 at 11:42
    
No problem. I should´ve written a shorter fix. The short_open_tag is by default disabled in newer versions of PHP. Since some programmers like to make it easy, they make these short open tags alot ;) Nojak filled in what I forgot to mention. Thanks againt Nojak :) –  Marcus Sjodin Jul 30 '12 at 12:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.