为什么简写 PHP 开头语句不起作用?
我正在尝试将我的 Mac 设置为 php 服务器,但是,尽管到目前为止我已经取得了成功,但我似乎遇到了一些麻烦。
我的 PHP 开头语句不起作用...但只有速记语句。
这有效:
<?php
phpinfo();
?>
这不行:
<?
phpinfo();
?>
这是 Mac 10.5。 希望有人可以提供帮助。
谢谢
I am trying to get my Mac setup as a php server, however, as successful as I have been so far, I seem to have run into a bit of bother.
My PHP opening statments are not working... but only the shorthand ones.
This works:
<?php
phpinfo();
?>
This doesn't:
<?
phpinfo();
?>
It's Mac 10.5. Hope that someone can help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 php.ini 中,设置 short_open_tag 至开。
来自文档:
编辑:
short_open_tag
是 PHP_INI_ALL 自 5.3.0 起< /a>,这意味着它可以在任何地方更改(php.ini、.htaccess、脚本中)。 而5.3.0之前是PHP_INI_PERDIR,也就是说可以在php.ini和.htaccess中设置。 因此,即使您不控制服务器,在大多数情况下您也可以更改其值。但是,此设置默认处于关闭状态。 如果您要分发脚本,则它无法在大多数开箱即用的安装中运行。 在这种情况下,搜索/替换切换到
是一个好主意。
In your php.ini, set short_open_tag to On.
From the docs:
Edit:
short_open_tag
is PHP_INI_ALL as of 5.3.0, which means that it can be changed anywhere (php.ini, .htaccess, in script). And it was PHP_INI_PERDIR before 5.3.0, which means that it can be set in php.ini and .htaccess. Therefore, you can change its value in most cases even if you don't control the server.However, this setting is off by default. If you are going to distribute your script, it won't work on most installations out of the box. In this case, a search/replace to switch to
<?php
is a good idea.检查您的 php.ini 文件是否包含
short_open_tag=1
< /a> 行。Check if your php.ini file contains the
short_open_tag=1
line.您是否验证了
short_open_tag
(请参阅此处) 在你的 php.ini 中启用了吗?Did you verify that
short_open_tag
(see here) is enabled in your php.ini?