Why </script> does not produce syntax parsing errors in PHP

Source: Internet
Author: User
Tags parse error php code php script

PHP as a mainstream web building language, in the use of the process there are many traps, the need for programmer ideas.
In the PHP script, if you write the following code
<?php
</script>
?>
This PHP script does not prompt any errors, but directly outputs the "?>". It was incredible, so we wrote the following code
<?php
</div>
?>
This time it prompts parse error, Parse error:syntax error, unexpected ' < ' in ...
Why did the first </script> not prompt the wrong?
Then we need to read the PHP manual again there are various ways of starting a block of PHP code:
You can use four pairs of different start and end tags in PHP. Two of these, <?php?> and <script language= "PHP" > </script> are always available. The other two are short tags and ASP style tags that 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, PHP has 4 tags in it, and <script> is one of them, and like <?php?>, it's always available, and the other two need to be open in the configuration file.
? ... ? > (open via Short_open_tag in configuration file)
<?php ...? >
<script language= "php" > ... </script>
<%%> (ASP style label, discard use in version 5.3.0)
This article links http://www.cxybl.com/html/wlbc/Php/20130601/38185.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.