我使用 xampp 进行本地开发,然后从直接安装程序安装了 PHP。 现在,在我的一些 PHP 代码中,只有以 "" 开头的 PHP 代码才能正确解析。 任何以“”或“”开头的内容都将被完全忽略并保持原样。
如何调整配置来解析任一令牌?
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?
发布评论
评论(6)
这是一个名为的 php.ini 设置
This is a php.ini setting named
我建议您禁用
short_open_tag
并且仅适用于
。 启用
short_open_tag
时,它可能会与 XML 发生冲突处理指令,因为 PHP 开放标记和 XML PI 都以
开头。
I recommend you to disable
short_open_tag
and only work with<?php
. Whenshort_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<?
.通过仅使用 作为预处理器启动,您可能会使预处理器与格式良好的 XML 文档混淆。 XML 代表 表示处理指令,想象一个带有嵌入 XML 且需要 XSLT 处理的 XHTML 文档...预处理器会与样式表处理指令混淆,并且会抛出一个错误。
强烈建议使用 处理器起始标签,尝试使用
Short_open_tag = 在 php.ini 中关闭。 另外,您可以尝试使用
如果您遇到问题。
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.您可以在 php.ini 中设置 Short_open_tag = On
You can set short_open_tag = On in the php.ini
这是一个配置选项,更多信息请参见:http://www.php.net/ini.core(查找short_open_tag)。
It's a configuration option, more information on: http://www.php.net/ini.core (look for short_open_tag).
对于较新版本:
For the newer version: