为什么php需要<?php标签? 简单<? 不起作用

I've just installed apache 2.2.22, php 5.3.15 and some other stuff on my Windows 7. At some point, the tag <? stopped working (apache now returns <? ..... ?> as plain HTML). After wasting a lot of time, I noticed that the full version of this tag <?php does work! How can I fix it without editing the code?

You must enable php short tags for <? and <?= to work in PHP < 5.4. Call ini_set('short_open_tag', true) or modify your php.ini if you can to specify it. Some hosts even allow a php.ini within the directory of the php script itself or you can customize your php.ini through your hosting panel.

Check your short_open_tag setting in php.ini.

Modify short_open_tag in php.ini

Using just <? ?> is bad practice so use <?php ?> or edit short_open_tag in your php.ini file.