开发者

I want to make PHP work with <? ?> and not with <?php ?>

开发者 https://www.devze.com 2023-01-23 14:10 出处:网络
I have got 2 laptops with the same win7 configs.The Apache/PHP/MySQL are the copy/paste from one to the other.But the PHP works only if <?php ?>开发者_StackOverflow is added on one, and works fi

I have got 2 laptops with the same win7 configs. The Apache/PHP/MySQL are the copy/paste from one to the other. But the PHP works only if <?php ?>开发者_StackOverflow is added on one, and works fine with <? ?> on the other laptop.

I do not want to change the all PHP tags from <? ?> to <?php ?>. How do I make the PHP work with <? ?>.


You need to enable short tags. Set short_open_tag to 1 in php.ini.

Prior to PHP 5.4, this enables both <? and <?= as alternatives to <?php and <?php echo respectively. In PHP 5.4, <?= is always on, so short_open_tag only controls the availability of <?.


Better idea: Change your code to use <?php. That way, it's more portable and you won't have to do the rewrite when you change servers.

If you really really want the shorthand and don't care about portability, change short_open_tag in your php.ini to 1.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号