PHP common symbols and functions-PHP tutorials

Source: Internet
Author: User
Tags autoload
Common PHP symbols and functions that PHP must know. Recently, some special PHP symbols were found when I was writing a PHP program, such as less than the symbol consecutively, three smaller than the symbol, eot, eod, echo, and print, suddenly I found that I used PHP for so long. recently I found some special PHP symbols when I was writing a PHP program. for example, I found three smaller than symbols, eot, eod, and echo examples, print example and so on, suddenly found that PHP has been used for so long, even the basic symbols of PHP are not fully recognized, see @ number also found for half a day to know what it means. sort the basic symbols and some common PHP symbols for ice bars on the outside into a list. post them on my blog. if you need them, refer to the special symbols related to PHP ~

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 (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

-Minus 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 <

> (Greater than) to>

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 <

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

$ FileName = "File. TXT ";

If (File_Exists ($ FileName )){

Echo"

&amp; Rdquo;. File_Get_Contents ($ FileName). &amp; rdquo; ";

} 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

Original article: http://y312ff.blog.163.com/blog/static/12701109420119119575812/

Lazycms: $ sysname

The first time I saw this expression, what does it mean by double colons?

A:

Directly belongs to the method or attribute of the class.

That is, the use of static methods or attributes.

Domain operators are generally used to use the attributes/methods of Class A objects in Class B objects!

Class c

{

Private static $ _ memory;

Public static function autoload ()

{

// Method body

}

}

C: $ _ memory;

C: autoload ();

...

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.