PHP Common special operation symbols and function summary (PHP beginners must SEE) _php skills

Source: Internet
Author: User
Tags bitwise string format

Callout symbol:
single-line annotation
Multi-line annotation
Use of Quotes
' single quotes, simple strings, without any processing directly brought over;
"" Double quotes, PHP dynamic processing and then output, generally used to process the $ variable.
Boolean variable:
One is true;
The other one is false or false.
Common variables:
string strings (digital \ Kanji \ etc.)
Integer integers (1, 2, 3, 4, 5, 0,-1,-2, etc.)
Double floating-point number (decimal point)
Array arrays
Object objects
The methods available are GetType ($mix) and Settype ($mix, $typename);

Common symbol Escape:

\ "Double Quotes
\ reverse Slash
\ n Line Change
\ r back to the beginning
\ t Horizontal Tabulation
operator Symbol:
+ addition operation-subtraction operation
* Multiplication Operations/Division operations
% to take remainder + + since add 1
--from minus 1. Connect two strings
Assignment Operation:
= Put the right value into the left
+ = Add the right value to the left
-= reduce the value on the right to the left
*= multiply the value on the left to the right.
/= divide the value on the left to the right.
. = Add the right string to the left
bit operations:
& Bitwise AND
| by bit or
^ Bitwise exclusive OR (XOR)
<< move 1-bit to the left
>> Move 1 digits to the right
~ Take the complement number
Logical Operations:
< less than > greater than
<= is less than or equal to >= greater than or equal
!= not equal to && and
||      Or! Non -
Other operational symbols
$ variable Symbol
& Variable Alias
@ Do not display error message (added to function)
Methods or properties of the-> object
The element value of the => array
?: Ternary operator

Common basic methods:

1.PHP conversion string is case-insensitive!

Strtolower (); Turn characters to lowercase
Strtoupper (); Capitalize the character

2.PHP Encrypted string

Not to be restored:
MD5 ();
SHA1 ();
To restore:
Base64_encode ();
Base64_decode ();

3. About Quotes

One, single quotation mark is the original output
Two, double quotes are content interpretation for output
The reverse single quotation mark (Keng number) is executed with a system command such as ' dir '. Commonly used in table names, field names above.
Four, "\" for the translation of characters, such as "\ n" for line wrapping.

4. Functions: Htmlspecialchars () and Htmlentities ()
This function converts special characters into an HTML string format (&....;). The most commonly used occasions may be to deal with the message version of the customer message.

& (and) Convert to &
"(double quotes) into"
< (less than) turn into <
> (greater than) convert to >
(space) turn into

5. Bulk Output HTML content!

Echo <<< EOT
HTML Output content ... Here the annotation still output!
EOT;

Print <<<eot
HTML Output content ... Here the annotation still output!
EOT;
(Note: Internal contains variables with "{variable}")

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

<?php
$FileName = "File.TXT";
if (file_exists ($FileName)) {
echo "<pre>". file_get_contents ($FileName). " </pre> ";
}else
{
echo "No";
}
?>

7. Delete variable release memory unset ();

Unset ($var);
Unset ($var, $var 1);

8.is_numeric;
Detect whether the variable is a number;

9.is_int;
Detects whether a variable is an integer;

10.is_null;
Detects whether the variable is NULL;

11.is_string
Detects whether a variable is a string

12.is_real;
Alias for Is_float ()

13.isset
Detect whether a variable is defined

14.is_bool
Detect whether a variable is a Boolean

15.is_array
Detects whether a variable is an array

16.is_object
Detects whether a variable is an object

The 17.SUBSTR () function returns part of the string.

SUBSTR (String,start,selectnum)

Copy Code code 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 () turns the escaped newline into an HTML <br/>

Copy Code code as follows:

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

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.