Home > php教程 > php手册 > body text

在PHP中, 为什么</script>不产生语法解析错误

WBOY
Release: 2016-06-21 08:49:46
Original
1498 people have browsed it

PHP作为主流网站建设语言,在使用过程中有很多陷阱,需要程序员主意。
在PHP脚本中,如果写如下代码

?>
这个php脚本并没有提示任何错误,而是直接输出了 "?>"。感觉很不可思议,于是我们再写如下代码

?>
这次却提示解析错误,Parse error: syntax error, unexpected '为什么第一次的不提示错误呢?
这时我们需要再仔细阅读一下PHP的相关手册了there are various ways of starting a block of PHP code:
可以在 PHP 中使用四对不同的开始和结束标记。其中两种, 总是可用的。另两种是短标记和 ASP 风格标记,可以在 php.ini 配置文件中打开或关闭。尽管有些人觉得短标记和 ASP 风格标记很方便,但移植性较差,通常不推荐。
也就是所,php的标签有4中,而<script>也是其中之一,并且和<?php ?>一样,总是可用的,其他的两种需要在配置文件中打开。<br/><? ... ?> (在配置文件中通过short_open_tag打开)<br/><?php ... ?><br/><script language="php"> ... </script>
(ASP风格标签,在5.3.0版中放弃使用)
本文链接http://www.cxybl.com/html/wlbc/Php/20130601/38185.html



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!