Annotation symbol:
// Single line Annotation
Multiline Annotation
Use of quotation marks
''Single quotes, a simple string that can be taken without any processing;
"" Double quotes, php dynamic processing and output, usually used to process $ variables.
Boolean variable:
True is true;
The other is false.
Common variables:
String (numbers, Chinese characters, etc)
Integer (1, 2, 3, 4, 5, 0,-1,-2, and so on)
Double Floating Point Number (decimal point)
Array
Object
Available methods include gettype ($ mix) and settype ($ mix, $ typename );
Common escape characters:
\ "Double quotation marks
\ Backslash
\ N line feed
\ R return to the beginning of the line
\ T horizontal tabulation
Operator number:
+ Addition operation-subtraction operation
* Multiplication/Division
% Return remainder + + auto-increment 1
-- Auto-subtract 1. connect two strings
Assignment operation:
= Place the value on the right to the left
+ = Add the right value to the left
-= Reduce the value on the right to the left
* = Multiply the value on the left by the value on the right.
/= Divide the value on the left by the value on the right
. = Add the string on the right to the left
Bitwise operation:
& Bitwise AND
| By bit or
^ Xor)
<Shifts 1 to the left
> Shifts one digit to the right.
~ Population
Logical operation:
<Less> greater
<= Less than or equal to> = greater than or equal
! = Not equal &
| Or! Non
Other operators
$ Variable symbol
& Alias for variables
@ Do not display the error message (before the function)
-> Object methods or attributes
=> Array element value
? : Ternary Operator
Common basic methods:
1. PHP converts strings to uppercase and lowercase!
Strtolower (); converts characters to lowercase letters
Strtoupper (); converts uppercase letters
2. PHP encrypted string
Unrecoverable:
Md5 ();
Sha1 ();
Recoverable:
Base64_encode ();
Base64_decode ();
3. quotation marks
I. Single quotes are output as is
2. Double quotation marks are output based on content Interpretation
3. A single quotation mark (small quotation mark) is used to execute a system command, such as 'dir '. Table names and field names are commonly used.
4. "\" acts on translated characters. For example, "\ n" is a line break.
4. Functions: htmlspecialchars () and htmlentities ()
This function converts special characters into HTML strings (&....;). The most common use case may be the message board for handling customer messages.
& (And) &
"(Double quotation marks)"
<(Less than) to <
> (Greater than) to>
(Space) to convert
5. Batch output HTML content!
Echo <EOT
HTML output content... // Comments are output here!
EOT;
Print <EOT
HTML output content... // Comments are output here!
EOT;
(Note: "{Variable}" is used for internal variables }")
6. Determine whether the file exists and the output content is file_exists ()
<? Php
$ FileName = "File. TXT ";
If (file_exists ($ FileName )){
Echo "<pre>". file_get_contents ($ FileName). "</pre> ";
} Else
{
Echo "no ";
}
?>
7. Delete the variable to release the memory unset ();
Unset ($ var );
Unset ($ var, $ var1 );
8. is_numeric;
Checks whether the variable is a number;
9. is_int;
Checks whether the variable is an integer;
10. is_null;
Checks whether the variable is NULL;
11. is_string
Checks whether the variable is a string.
12. is_real;
Is_float () alias
13. isset
Check whether variables are defined
14. is_bool
Check whether the variable is Boolean
15. is_array
Checks whether the variable is an array.
16. is_object
Checks whether a variable is an object.
17. The substr () function returns part of the string.
Substr (String, Start, SelectNum)
Copy codeThe Code is as follows:
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
18. nb2br () converts the escape line to html. <br/>
Copy codeThe Code is as follows:
Echo nl2br ("foo isn't \ n bar ");