Php basics (1)-tag style, comment, form acquisition, string type, and variable Parsing

Source: Internet
Author: User
Tags php basics

PHP tag style:

// Recommended tag style, which can be used in XML documents <? Php '<p> XML Style </p>';?> <? '<P> Short Style </p>';?> <% '<P> Asp Style </p>'; %> <script language = 'php;> echo '<p> Script Style </p> '; </script>

 

 
 
 
 
For example, "" will be treated as HTML because it is outside of the flag
 

 

['Name' ['name' ['name' ['name'];


/* Short Style
Form variables are automatically converted to global variables and may encounter program errors that compromise Script Security.
In use, you must assign an initial value to your variables.
*/
It involves retrieving variables from one of the $ _ POST, $ _ GET, or $ _ REQUEST arrays.
These three arrays are called superglobal variables.
$ _ GET depends on the method used to submit the form (POST or GET), but data can be obtained through ['name ']
*/
Expired. The performance can be improved after being disabled
*/

 

 
"Character string" // single quotation mark ('') 'character string'
<Introduced later)
Echo <"(introduced after PHP5.3.0) <'eot' EOT;

1. Single quotes
To express a single quotes, you must add a backslash (\To express a backslash itself, use two backslash (\\).
Any other method of the backslash will be treated as the backslash itself,
For example\ ROr\ N, Does not represent any special meaning, just the two characters themselves.
2. Double quotation marks
  
Strings are enclosed in double quotes ("). PHP will parse some special characters.
3. Heredoc Structure
<, Provide an identifier (, and then wrap it,
Next is the string itself,
Finally, use the identifier defined above as the end mark.
  

Notes
1. Double quotation marks and Heredoc structure are interpolation []
2. Differences and efficiency between the Heredoc syntax and the Nowdoc syntax with single quotes:
Because the double quotation marks/Heredoc syntax requires interpolation, the fields in them will be interpreted by the compiler and then output as HTML code;
Fields in the single quotes/Nowdoc syntax are not interpreted and output directly.
3. When the Heredoc structure/Nowdoc structure ends, the referenced identifier must be in the first column of the row,
The end identifier line cannot contain any other character except a semicolon,
There cannot be any blank or tabs before and after the semicolon.
* Be careful when the Heredoc structure contains complex variables.
4. After PHP5.3.0, The Heredoc structure is used to initialize the attributes and constants of static variables and classes:
  = <<<... BAR = <<<  = <<<
 
  = <<<'EOT'
 
Appendix: escape characters
\ N line feed (LF or 0x0A (10) In the ASCII character set ))
\ R press enter (CR or 0x0D (13) in the ASCII character set ))
\ T horizontal tab (HT or 0x09 (9) In the ASCII character set ))
\ V vertical tab (VT or 0x0B (11) In the ASCII character set) (from PHP 5.2.5)
\ E Escape (ESC or 0x1B (27) in the ASCII character set) (from PHP 5.4.0)
\ F form feed (FF or 0x0C (12) in the ASCII character set) (since PHP 5.2.5)
\ Backslash
\ $ USD mark
\ "Double quotation marks
\ [0-7] {} matches the regular expression sequence and is a character expressed in octal mode.
\ X [0-9A-Fa-f] {} matches the regular expression sequence and is a character expressed in hexadecimal notation.
*/

 


# Deep Learning about variable Parsing

 

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.