Why not a syntax parsing error occurs in PHP?

Source: Internet
Author: User
Tags parse error

In PHP, why does </SCRIPT> not show a parse error?

In PHP, why does </SCRIPT> not produce syntax parsing errors?

As a mainstream website construction language, PHP has many traps and requires the programmer's idea.

In the PHP script, if you write the following code:

<? Php </SCRIPT>?>

This PHP script does not prompt any errors, but directly outputs "?> ". This is incredible, so let's write the following code:

<? Php </div>?>

This time the parsing error is prompted, parse error: syntax error, unexpected '<' in...

Why does the first </SCRIPT> prompt no error?

At this time, we need to carefully read the relevant PHP manual there.
Are various ways of starting a block of PHP code:

You can use four different start and end tags in PHP. Two of them, <? PHP?> And <script language = "php"> </SCRIPT> are always available. The other two are short tag and asp style tag, which can be opened or closed in the PHP. ini configuration file. Although some people think that short tag and asp style tag are very convenient, but the portability is poor, it is generally not recommended.

That is, PHP has four tags, and <SCRIPT> is one of them, and? PHP?> Same, always available. The other two must be opened in the configuration file.

  1. <? ...?> (Open through short_open_tag in the configuration file)
  2. <? PHP...?>
  3. <Script language = "php">... </SCRIPT>
  4. <%... %> (ASP style label, which is not used in version 5.3.0)

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.