Basic symbols in PHP and how to use them
Core tip: With so long, even PHP basic symbols are not recognized, see the @ is also checked for a long time to know what meaning. Put a list of basic symbols, you need a friend to refer to.
With so long, even PHP basic symbols are not recognized, see the @ is also checked for a long time to know what meaning. Put a list of basic symbols, you need friends can refer to ~
Annotation symbols:
?
Single-line annotations /* * * Multi-line annotations |
?
Use of quotation marks
?
' Single quotation marks, without any meaning, are brought directly over by any treatment; "" Double quotes, PHP dynamic processing then output, typically used for variables. |
?
Variable pattern:
?
One is true, that is true; The other is false or false. |
?
Common variant Patterns:
?
string strings (numeric \ Kanji \ etc) Integer integers (1, 2, 3, 4, 5, 0, 1, 2, and so on) Double floating point number (decimal point) Array arrays Object objects |
?
Available methods are GetType ($mix) and Settype ($mix, $typename);
Common symbols
?
\ "Double quotation marks \ \ Backslash \ nthe line break \ r send out \ t-hop (TAB) |
?
Operation symbols
?
+ addition operations-subtraction operations * Multiplication Operation/division operation % take remainder + + accumulate --minus 1. Add the strings together |
?
Set operation
?
= Put the value on the right to the left (must be) + = Add the right value to the left -= reduce the value on the right to the left *= multiply the left value by the right. /= divide the left value to the right . = Add the right string to the left |
?
Bit operator
?
& and | Or ^ Mutex (XOR) << left Shift >> Right Shift ~ Take 1 of the complement |
?
Logical operations
?
< less than > greater than <= less than or equal to >= greater than or equal ! = does not equal && and || Or! No |
?
Other operational symbols
?
$ variable Symbol Indicator of the & variable (before the variable) @ Do not display error message (added before function) The method or property of the object = = element value of array ? : Ternary operator |
?
Basic methods
1.PHP convert string to case!
?
Strtolower (); Turn character to lowercase Strtoupper (); Turn characters into uppercase |
?
2.PHP Encrypted string (case-sensitive)
?
MD5 (); encryption SHA1 (); encryption |
?
3. About quotation marks
One, single quotation marks are output as-is
Two, double quotation mark is the content explanation carries on the output
Third, anti-single quotation marks are the execution of a command, such as ' pwd '.
Four, "\" role in the translation of characters, such as "\ n" for line-wrapping!
4. Function: Htmlspecialchars ()
This function turns special characters into HTML string format (&....;). The most commonly used occasion may be to deal with the message of the customer message version.
?
& (and) turn into & "(double quotation marks) to turn" < (less than) turn into < > (greater than) turn into > |
?
This function converts only the above special characters, and does not convert all of the ASCII conversions specified by the HTML.
5. Batch Output HTML content!
?
Echo <<< EOT HTML Output content ... Here the comment output! EOT;
Print << HTML Output content ... Here the comment output! EOT; |
(Note: internal contains variable with "{variable}")
6. Determine if the file exists and output the content
?
$FileName = "File.TXT"; if (file_exists ($FileName)) { Echo " ". File_get_contents ($FileName). " "; }else { Echo "No"; } ?> |
7. Unload variable unset;
?
Unset ($var); Unset ($var, $var 1); |
8.is_int;
Detects if the variable is an integer;
9.is_null;
Detects if the variable is NULL;
10.is_string
Detects if a variable is a string
11.is_real;
Alias for Is_float ()
12.isset
Detect if a variable is set
13.is_bool
Detects if a variable is a Boolean type
14.is_array
Detects if a variable is an array
15.is_object
Detects if a variable is an object
16.SubStr.
?
SUBSTR (String,start,selectnum) echo substr (' abcdef ', 1); Bcdef echo substr (' abcdef ', 1, 3); Bcd echo substr (' abcdef ', 0, 4); Abcd echo substr (' abcdef ', 0, 8); ABCdef echo substr (' abcdef ',-1, 1); F |
17.nb2br
?
echo nl2br ("foo isn ' t\n bar"); |
To turn an escaped newline into HTML.