Php-manual's Learning----"Language Reference"

Source: Internet
Author: User
Tags integer division type null

June 28, 2017 11:29:31

Language Reference
Basic syntax
Type
Variable
Constant
1. 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.
2. 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.
3. PHP files can have mixed content. Allows PHP to be embedded in HTML documents.
4. Anything outside a pair of start and end tags will be ignored by the PHP parser
5.short_open_tag must be set in php.ini if you want to use a short tag.
6.PHP needs to end the instruction with a semicolon after each statement. An end tag in a PHP code implies a semicolon; the last line in a PHP snippet can end without a semicolon. If there are new rows later, the end tag of the snippet contains the end of the line.
7. Single-line Comment://comment Content Comment:/* Comment content */
The 8.PHP supports 8 raw data types.
Four types of scalar:
? Boolean (Boolean)
? Integer (integer type)
? Float (floating-point, also called double)
? String (String)
Two kinds of composite types:
? Array (arrays)
? Object (Objects)
Finally, there are two special types:
? Resource (resources)
? NULL (no type)
9. The type of the variable is usually not set by the programmer, rather, it is determined by the context in which PHP is used by the variable at run time.
10. If you want to see the value and type of an expression, use the Var_dump () function.
1. Variables show different values depending on the type of their time
2.boolean expresses the TRUE value, which can be false.
3. When converting to Boolean, the following values are considered FALSE:
? The Boolean value FALSE itself
? Integer value 0 (0)
? Floating-point value 0.0 (0)
? An empty string, and the string "0"
? An array that does not include any elements
? Objects that do not include any member variables (PHP 4.0 only applies)
? Special type NULL (including variables that have not been assigned)
? SimpleXML object generated from an empty tag
4. An integer is a collection? = {...,-2,-1, 0, 1, 2, ...} a number. To use octal expressions, the number must be preceded by 0 (0). To use hexadecimal representation, the number must be preceded by 0x. To use binary representations, the number must be preceded by a 0b
5. If a given number exceeds the range of integers, it will be interpreted as float. Also returns a float if the result of the operation is outside the integer range
Operators that do not have an integer division in 6.PHP. 1/2 produces a float of 0.5. The value can be cast to integer by discarding the fractional part, or better rounded with the round () function.
7. To explicitly convert a value to an integer, cast with (int) or (integer). However, in most cases there is no need to cast, because when an operator, function, or process control requires an integer parameter, the value is automatically converted. You can also convert a value to an integral type by using the function intval ().
8. A string of strings consists of a series of characters, each of which is equal to one byte. This means that PHP can only support a 256 character set and therefore does not support Unicode
9. String can reach 2GB maximum.
10. A string can be expressed in 4 different ways:
? Single quotation marks
? Double quotes
? HEREDOC syntax structure
? NOWDOC syntax structure
1. Single quotation marks
The simplest way to define a string is to enclose it in single quotation marks (characters ').
To express a single quotation mark itself, you need to escape it by adding a backslash (\) in front of it. To express a backslash itself, use two backslashes (\ \). Any other backslash is treated as a backslash itself: that is, if you want to use a different escape sequence such as \ r or \ n, it does not represent any special meaning, it is simply the two characters themselves.
2.

Php-manual's Learning----"Language Reference"

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.