Home  >  Article  >  Backend Development  >  In PHP, why does </script> not generate syntax parsing errors_PHP Tutorial

In PHP, why does </script> not generate syntax parsing errors_PHP Tutorial

WBOY
WBOYOriginal
2016-07-14 10:07:321265browse

As a mainstream website construction language, PHP has many pitfalls during use, which requires programmers to think.

In PHP script, if you write the following code
?>
This php script did not prompt any errors, but directly output "?>". It feels incredible, so we write the following code
?>
This time it prompted a parsing error, Parse error: syntax error, unexpected '<' in ...
Why does the first not prompt an error?
At this time we need to read the relevant manuals of PHP carefully. There are various ways of starting a block of PHP code:
Four different pairs of opening and closing tags can be used in PHP. Two of them, and are always available. The other two are short tags and ASP style tags, which can be turned on or off in the php.ini configuration file. Although some people find short tags and ASP-style tags convenient, they are less portable and generally not recommended.
That is to say, there are 4 tags in php, and <script> is one of them, and like <?php ?>, it is always available. The other two need to be opened in the configuration file . </div> <div> </div> <div><? ... ?> (Open via short_open_tag in configuration file)</div> <div><?php ... ?> </div> <div><script language="php"> ... </script>
<% ... %> (ASP style tag, abandoned in version 5.3.0)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477852.htmlTechArticleAs a mainstream website construction language, PHP has many traps during use, which requires programmers to be aware of. In a PHP script, if you write the following code ?php /script ? This php script does not prompt any...
Statement:
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