PHP operator Summary

Source: Internet
Author: User

Recently, some special PHP symbols were found when I was writing a PHP program, such as less than the symbol consecutively, three less than the symbol, EOT, EOD, Echo, print, and so on. Suddenly
I found that after using PHP for so long, I even didn't fully recognize the basic symbols of PHP. I saw the @ number and found out what it meant for a long time. sort the basic symbols and some common PHP symbols on the ice bar into columns.
Table. post it on my blog. For more information, see PHP-related special symbols ~

Annotation symbol:

// Single line Annotation

/**/Multi-line Annotation

Use of quotation marks

''Single quotes, no meaning, can be taken without any processing;

"" Double quotes, PHP dynamic processing and output, usually used for variables.

Variable form:

True is true;

The other is false.

Common variables:

String 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 symbols

\ "Double quotation marks

\ Backslash

\ N line feed

\ R output

\ T hop (Tab)

Operator number

+ Addition operation-subtraction operation

* Multiplication/Division

% Get remainder + + accumulate

-- Accumulate 1. Add strings

Set operation

= Place the value on the right to the left (yes)

+ = 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 Operator

&

| Or

^ Exclusive (XOR)

<Shift left

> Shift to the right

~ 1 Population

Logical operation

<Less> greater

<= Less than or equal to> = greater than or equal

! = Not equal to & and

| Or! No

Other operators

$ Variable symbol

& Variable indicators (before the variable)

@ Do not display the error message (before the function)

-> Object methods or attributes

=> Array element value

? : Ternary Operator

Basic Method

1. php converts strings to uppercase and lowercase!

Strtolower (); converts characters to lowercase letters
Strtoupper (); converts uppercase letters

2. php encrypted string (case sensitive)

MD5 (); encryption
Sha1 (); encryption

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 is used to execute a command, such as 'pwd '.
4. "\" acts on translated characters. For example, "\ n" is a line break!

4. function: htmlspecialchars ()
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 & lt;
> (Greater than) to & gt;

This function only converts the preceding special characters and does not convert all of them into the ASCII conversion defined in HTML.

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

<? PHP
$ Filename = "file. txt ";
If (file_exists ($ filename )){
Echo "<XMP>". file_get_contents ($ filename). "</XMP> ";
} Else
{
Echo "no ";
}
?>

7. unset the variable;

Unset ($ var );
Unset ($ var, $ var1 );

8. is_int;
Checks whether the variable is an integer;
9. is_null;
Checks whether the variable is null;
10. is_string
Checks whether the variable is a string.
11. is_real;
Is_float () alias
12. isset
Check whether the variable is set
13. is_bool
Check whether the variable is Boolean
14. is_array
Checks whether the variable is an array.
15. is_object
Checks whether 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 ");
Convert the escape line into HTML <br/>

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.