Why is “<?” no longer working and instead only “<?php” works?

拥有回忆 提交于 2019-12-07 01:53:56

问题


I was using xampp to develop locally and then I installed the PHP from the direct installer. Now in some of my PHP code, only PHP code that starts with "<?php" is correctly parsed. Anything that starts with "<?" or "<?=" is completely ignored and just left as is.

How can I adjust the configuration to parse either tokens?


回答1:


This is a php.ini setting named

short_open_tag = 1 # (enabled)



回答2:


I recommend you to disable short_open_tag and only work with <?php. When short_open_tag is enabled, it can collide with the XML processing instruction <?xml as both the PHP open tag and XML PI start with a <?.




回答3:


By using only <? as start preprocessor startup, you can get the preprocessor confused with well formed XML documents. XML stands <? for processing-instruction, imagine an XHTML document with embeded XML that requires XSLT processing... The preprocessor will get confused with the stylesheet processing instruction and will throw an error.

It's higly recomended to use the <?php processor starting tag, try using the short_open_tag = Off in your php.ini. Also, you can try using <?php ini_set('short_open_tag', 'On'); > if you are getting problems.




回答4:


You can set short_open_tag = On in the php.ini




回答5:


It's a configuration option, more information on: http://www.php.net/ini.core (look for short_open_tag).




回答6:


For the newer version:

short_open_tag = On


来源:https://stackoverflow.com/questions/435705/why-is-no-longer-working-and-instead-only-php-works

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!