PHP common special operation symbols and function summary of php beginners must see

  • 2020-05-27 04:37:00
  • OfStack

Annotated symbols:
// one-line notes
Multi-line comment
Use of quotation marks
"Single quote, simple string, brought in without any processing;
"" double quotes,php dynamic processing and then output,1 generally used to handle the $variable.
Boolean variable:
One is true which is true;
The other is false, which is fake
Common variables:
string string (Numbers, Chinese characters, etc.)
integer integers (1, 2, 3, 4, 5, 0, -1, -2, etc.)
double floating point number
array array
object object
The available methods are gettype($mix) and settype($mix,$typename);

Common symbol escape:

\ "double quotation marks
\ \ the backslash
\ n newline
\ r back to the beginning of a line
\t horizontal tabulation
Operation symbol:
Plus plus minus minus
* multiplication/division
Take the remainder of % ++ add 1
Concatenate two strings
Assignment operation:
= substitute the value on the right into the value on the left
+= add the right-hand side to the left-hand side
-= subtract the right-hand side from the left-hand side
*= multiply the left-hand side by the right-hand side
/= divide the left-hand side by the right-hand side
.= add the right string to the left
& Bitwise and
| or by location
^ by bit or (xor)
< < We're going to move 1 bit to the left
> > I'm going to move 1 bit to the right
~ take a complement
Logical operation:
< Less than > Is greater than
< Is less than or equal to > Is greater than or equal to
! = is not equal to & & with
| | or! non
Other operation symbols
$variable symbol
& Variable alias
@ does not display error message (added before function)
- > Object's methods or properties
= > The element values of the array
? : 3 meta operator

Common basic methods:

1.PHP converts strings to case!

strtolower (); Convert characters to lowercase
strtoupper (); Convert characters to uppercase

2.PHP encrypted string

Can restore:

3. About quotation marks

1. Single quotes are output as is
2. Double quotation marks are content interpretation for output
3. Anti-single quotes (small quotes) are the execution of a system command, such as' dir '. Often used in table names, field names above.
4. "\" ACTS on the translated characters, such as "\n" for line feed.

4. Functions :htmlspecialchars() and htmlentities()
This function converts a special character to the string format of HTML ( & . ; ). One of the most common situations is probably the message board for customer messages.

& (and) turn into & amp;
"(double quotation marks) & quot;
< PI is less than PI & lt;
> (greater than) into & gt;
(blank) into & nbsp;

5. Batch output HTML content!

echo < < < EOT
HTML output content... // comments are still output here!

print < < < EOT
HTML output content... // comments are still output here!
(note: "{variable}" is used for internal containing variables.)

6. Determine whether the file exists and output the content file_exists ()

< ?php
if (file_exists($FileName)){
echo " < pre > ".file_get_contents($FileName)." < /pre > ";
? >

7. Delete variables to free memory unset();


Test whether the variable is a number;

Test whether the variable is an integer;

Test whether the variable is NULL;

Detects whether the variable is a string

is_float (alias)

Detects whether a variable is defined

Test whether the variable is Boolean

Detects whether the variable is an array

Detects whether a variable is an object

The 17.substr() function returns part 1 of the string.

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

18.nb2br() changes the escaped newline to html < br / >

echo nl2br("foo isn't\n bar");

Related articles: