PHP Basic Syntax Primer (1) _php tutorial

Source: Internet
Author: User
Tags closing tag php server
Detach from HTML

PHP scripts are caused by a special set of tags in the file, and when the interpreter parses a file, all ordinary files outside of the special tag are not processed by the interpreter, and the files within the special tag are interpreted as PHP code by the parser. The operating mechanism will allow you to embed PHP code in HTML: Content outside the PHP tag will be completely independent, without any processing, and the internal will be parsed as PHP code.

There are four sets of tokens used to mark PHP blocks, of which only two are always valid ( and), and the other two can be turned on or off in the php.ini configuration file. Although short-form markup and ASP-style markup may be less labor-saving, in some cases you may have to use long-form markup. For example, if you intend to embed PHP code in XML or XHTML, you will need to use the form of markup to adapt to the XML standard.

The tags supported by PHP are:

 1. !--? php  echo (  "If you want to serve XHTML or XML documents, does like Thisn"   ?> 

2. echo ( "This was the simplest, an SGML processing Instructionn" ?>
!--? = Expression?--> this is a sho Rtcut for " echo expression,
3.

4. <% Echo ("may optionally use Asp-style tags");%>
<%= $variable; # This was a shortcut for "<% echo ..."%>

The preferred approach is in the first way , because it allows you to use PHP in XML structures such as XHTML code.

The second approach is not always available. Only available if you activate the Short_open_tag option in the php.ini configuration file. You can also activate short format tags by using the Short_tags () function (PHP 3 only) or by using the--enable-short-tags option configure PHP. In the Php.ini-dist configuration file, the short format tag is turned on by default, but it is recommended that you do not use the tag.

Turning on the option Asp_tags in the PHP configuration file will activate the fourth way.

Note : ASP-style markup added to PHP 3.0.4

Note : When developing a large application or a library of functions for distribution, or developing a program on a PHP server that is not under your control, do not use short-form markup, because the target server may not support short-form markup. For portability, ensure that short-form markup is not used in the code that is used for redistribution.

The PHP code block end Tag award automatically contains a new line (if one exists) at the end of the most recent. Also, the end tag automatically implies a semicolon; You do not need to append a semicolon to the last line of the PHP code block.

PHP allows you to use the following structure:

Higher-level disengagement

      this is true.  
      this is false.< /strong> 
     

PHP will directly output the closing tag and any non-PHP code in the next start tag. When you need to output a large amount of text, exiting PHP parsing mode will be more effective than printing all the text using echo () or print () or a function of this class. 1

http://www.bkjia.com/PHPjc/446738.html www.bkjia.com true http://www.bkjia.com/PHPjc/446738.html techarticle The script that separates PHP from HTML is caused by a special pair of tags in the file, and when the interpreter parses a file, the interpreter does not do it with all the ordinary files outside of the special tags ...

  • 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.