很多站长朋友们都不太清楚php支持短标签,今天小编就来给大家整理php支持短标签,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php.ini 中如何开启短标签 2、 php怎么开启短标签 3、 php短标签 作用 4、 php怎样开启短标签short 5、 如何使php支持短标记 php.ini 中如何开启短标签如果设置为Off,则不能正常解析类似于这样形式的php文件:
<?
phpinfo()
?>
而只能解析
<?php
phpinfo()
?>
这样形式的php文件
所以要想php支持短标签,需要我们把short_open_tag
设置为On.
php怎么开启短标签方法/步骤
1
这里列出了php的两种标签,一种是<?php ?>另一种是<??>,也称为短标签
2
r如何,使程序里能用第二种短标签呢,这就需要我们开启短标签的配置了,找到php的配置文件,右击使用文本编辑器打开
3
查找 short_open_tag
4
找到配置的行
5
修改成short_open_tag=On,如果已经是On了就说明短标签已经开启了,无需再设置了
6
上诉步骤完成后,保存关闭文件,重启启动php环境,这时php的短标签就生效了
php短标签 作用<?在php.ini里面
short_open_tag = Off
也被称为短标签
提倡的都是<?php ?>, 禁用<? ?>,因为短标签会破坏原生xml模板
官方给的解释是
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
意思就是这玩意打开了可以用,但是不建议使用
<?php
echo "";
?>
这才是规范的写法
用<?php ?>你永远不会出问题;而用<? ?>会可能出问题
例如:配置文件没有开启短标识
例如:<?xml version="1.0" ?>会被当作php
php怎样开启短标签short1.看php的配置环境,如果short_open_tag 没有开启,找到php.ini打开php.ini
2.打开php.ini配置文件,查找“ short_open_tag ”short_open_tag = Off 修改成short_open_tag = On
3.开启以后重启apache的,然后在看一下php的配置信息,就修改short_open_tag = on
如何使php支持短标记我用的是WAMP的集成环境,刚开始只在php中的php.ini文件中将short_open_tag设为on,但是仍然无法使用短标签。
这里我的解决方法:首先输出phpinfo(),查看Loaded Configuration File的目录,看下你载入的配置文件跟你修改的配置文件路径是否一致。改好之后记得重启Apache哦。
关于php支持短标签的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于php支持短标签 php script标签的详细内容...