当前位置:网站首页>short_open_tag 短开放标签 必须打开
short_open_tag 短开放标签 必须打开
2022-04-21 17:06:00 【L.Cheng】
今天在我的 CentOS VPS 上使用 <?= ?> 指令对模板PHP文件做直接输出时,发现根本无法输出,于是去找原因,发现CentOS 的 php.ini 默认会关闭短开放标签的功能(Short Open Tag),也就是不能使用 <? ?> 标签,只要把短开放标签重新打开即可。
对于 PHP 5.4 以前的版本,如果关闭的短开放标签,就不能再使用 <?= ?> 进行输出了,而对于 PHP 5.4+,不论是否关闭了短开放标签功能,都可以使用 <?= ?> 进行输出。
具体 CentOS 的开发者为什么想要在默认配置里关闭短开放标签,可能是因为短开放标签与XML文件头冲突的原因吧(<?xml version="1.0"?>)。
个人觉得,编写AJAX程序时候,使用JSON代替XML要方便得多。
在执行项目时php中报syntax error, unexpected end of file in这个错误,我们往往会排查是否缺标点符号之类的。
但是,使用编辑器的原因,有这个错误编辑器却没有反馈出来,而且,也仔细检查了代码,也是没问题。
这个时候就要想想是不是其他地方有问题了。
新的公司,在php文件中使用了php的段标签,其实很常见。但是,新搭的环境却不一定支持。
修改php.ini文件:
short_open_tag = Off为on
short_open_tag作用:
在php的配置文件(php.ini)中有一个short_open_tag的值,开启以后可以使用PHP的段标签:(<? ?>)。
同时,只有开启这个才可以使用 <?= 以代替 <? echo 。在CodeIgniter的视频教程中就是用的这种方式。
但是这个短标签是不推荐的,使用<?php ?>才是规范的方法。只是因为这种短标签使用的时间比较长,这种特性才被保存了下来。
版权声明
本文为[L.Cheng]所创,转载请带上原文链接,感谢
https://blog.csdn.net/hi1234560/article/details/124312673
边栏推荐
- IO view command
- MySQL: 1103 error solution
- Win10 bridging network card enables QEMU virtual machine to access the network normally
- 机器学习吴恩达课程总结(二)
- R language uses qbern function to generate Bernoulli distribution (0-1 distribution) quantile function data, and uses plot function to visualize Bernoulli distribution
- Redis 做分布式锁的常见问题和解决方案
- 2022 new air outlet! The tide of it crowd research is coming!!!
- MySQL查询语句关键字执行的优先级问题
- 338 leetcode isomorphic string
- BUUCTF WEB [网鼎杯 2018]Fakebook
猜你喜欢

Quick MTF,镜头图像质量测试应用程序

Priority of keyword execution of MySQL query statement

Vivado验证Vitis HLS生成的IP核

Extensive reading of alexnet papers: landmark papers in the field of deep learning CV neurips2012

吴恩达机器学习详细总结(三)

mysql:1103 错误解决方案

Multilingual communication foundation 04 grpc and protobuf

Sqli labs 23-25a breakthrough experience and ideas

.NET Core企业微信网页授权登录

Vitis HLS build project and generate IP core (vivado HLS)
随机推荐
mysql为数据库表起别名的注意事项
下载vscode离线插件包的网址
A simple and easy-to-use file upload scheme
IO view command
【微服务】微服务安全 - 如何保护您的微服务基础架构?
DPI发布AI药物研发最新进展报告
R语言使用dplyr包中的select函数基于数据列的索引数值删除dataframe中数据列
mysql:1103 错误解决方案
使用epoll时需要将socket设为非阻塞吗?
微服务架构统一安全认证设计与实践
The R language uses the plot function to visualize the data scatter diagram, and uses the BG parameter in the par function to customize the background color in the wireframe of the visual image
R language uses cor function to calculate the correlation coefficient between multiple numerical data columns in dataframe and Pearson product moment correlation coefficient
【newcode】牛牛组队竞赛
338-Leetcode 同构字符串
/etc/passwd的利用
wx-open-launch-weapp 样式问题
338 leetcode isomorphic string
pytorch index_ add_ Usage introduction
Summary of Wu Enda's course of machine learning (I)
Redis三种模式——主从复制,哨兵模式,集群