Solved: New WAMP Install Won’t Parse PHP

I spent ages trying to figure out why my new installation of WAMP Server 2 wouldn’t parse my PHP and was spitting it out exactly as-is in the source file. I hoked around in the VirtualHost configuration, because the PHPMyAdmin that comes with WAMP Server was working fine so it had to be something wrong in the VirtualHost that I just configured that was stopping .php files being sent to the PHP parser, yes? No.

As it turns out, it’s much simpler than that. Apache was sending the file to PHP to be parsed, but PHP was ignoring my code. Why? WAMP Server 2 comes with “short open tags” turned off (this may be a general PHP or PHP 5 thing, though not sure). Click WAMP -> PHP -> php.ini to edit the aforementioned file and find the line:

short_open_tag = Off

Replace Off with On et voila.

The ‘more correct’ though long-winded solution is to replace all your <? opening tags with <?php if you’re really keen (though that’ll also mean replacing <?= with <? echo). Me, I think I like my short tags.

Author: nerd.

An experienced IT professional, I used to run a number of small websites and spend a lot of time tinkering with my sites or my PC - back when I had free time.

7 thoughts on “Solved: New WAMP Install Won’t Parse PHP”

  1. I don’t know if you’re aware, but most web hosts come with this turned off these days, so IMO it makes more sense to get into the habit of doing it the long way around locally. Not a big deal if you only ever use the same host but at work ‘we’ use multiple solutions so it’d be a pain in the butt to have to change everything up if I move a site from server to another.

  2. Thanks for the advice Jem. I’d like to say I’ll bare it in mind but typing php after every opening tag is far too much of a pain in the arse, especially since I’m not creating most of my sites from scratch. I think it’s also a bad policy so I suppose I’m protesting a little: aside from the initial <?xml line, what else is it going to be in a .php file?

  3. I really can’t believe I missed this, but thank you very much! Big time saver, but as Jem said better to change habits. Too many times I’ve deployed to a server and… ‘Doh’! 🙂

    Although, who would argue with “…typing php after every opening tag is far too much of a pain in the arse…”.

  4. Hello guys,
    I am using wamp and really want to use which saves me space and makes the code look excellent
    I have already searched for short_open_tag,and the thing is that its already on and I still can’t use the which makes me angry.

    I am using apache 2.2.11 with php 5.3.0

    what on earth am I missing?

  5. Thank you so much for this. Yesterday i had spent most of my time in finding out why it was giving me this error. Finally i know..
    Will always keep this in mind..

Leave a Reply

Your email address will not be published. Required fields are marked *