What is a PHP tag? Four styles of PHP markup

Source: Internet
Author: User
When parsing a file, PHP looks for the start and end tags, which is <?php and, which tells PHP to start and stop parsing the code between the two. This parsing allows PHP to be embedded in a variety of different documents, and any part outside the start and end tags will be ignored by the PHP parser.

PHP also allows the use of short mark < And, but not encouraged to use. Short marks can be used only by activating the Short_open_tag configuration directive in php.ini or by using the configuration option--enable-short-tags when compiling PHP.

If the file content is pure PHP code, it is best to remove the PHP end tag at the end of the file. This avoids having to accidentally add a space or line break after the PHP end tag, which causes PHP to start outputting these blanks, and there is no intention to output the script at this time.

<?phpecho  "Hello World";//... more codeecho  "last statement";//script ends with no PHP end tag

Introduction to 4 types of markup styles in PHP

1.xml Style (recommended for standard style)

<?php echo "This is the markup of the XML style";?>

XML-style markup is a common tag and is the recommended tag, and the server cannot be disabled, and the style tag can be used in xml,xhtml.

2. Scripting style

<script languange= "PHP" > Echo ' This is the script style tag '; </script>

3. Short style

< This is a short-style mark; >

Note: You need to set short _open_tag=on in php.ini, default is on, or add the –enable-short-tags option when PHP is compiled. (PHP version 3 can also be activated with the Short_tags () function by using the short tag.) )
4.asp style

<% Echo ' This is an ASP-style tag '; %>

Note: Asp_tags = On is required to be turned on in the php.ini configuration file;

The above ASP style and short style need to be set in php.ini. The default is not supported.

Note: Support for ASP style tagging is added in version 3.0.4.

Note: You should avoid using short marks when developing programs or libraries that need to be released, or on servers that the user cannot control. Because the target server may not support short tokens. For code porting and distribution, be sure not to use short marks.

Related Article

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.