Tamping the basics of PHP learning-1

Source: Internet
Author: User

1, the difference between single and double quotation marks

    • Single quotes represent strings, double quotes can parse variables in a string, so if there are no variables, try to use single quotes to speed up parsing
    • When a string needs a single or double quotation mark, you can replace it with an escape character

2, type conversion

    • Type conversion via (Boolean)
    • Type conversion via bool Settype (mix var, string type), conversion succeeds, returns true, otherwise false
    • The difference between the two is that the original variable after a conversion, b after conversion, the original variable changed to become the converted Variable

3, detection data type,

    • Use a series of functions such as is_bool to detect, such as whether the detection is a number, is_numberic to detect is not a number type

4, use define to define constants,

    • The format is define (string Name,mix value,case_sentive); The last parameter indicates whether case sensitive, true indicates insensitive
    • Use defined to determine whether or not to define
    • System constants, commonly used __file__ to represent file paths

5, assigning values to variables,

    • Reference assignment and direct assignment, the direct assignment is directly equal to, the reference assignment is represented by &, when the reference assignment, the value changes, the reference also changes

6, variables include local variables, global variables, static variables, the difference is

    • Local variables are only useful inside functions
    • Global variables are useful throughout the PHP file, but are useless in user-defined functions, and if you want to use them in custom functions, declare them with global before customizing them, as follows
<?  $test = ' Hello Test '; function echotest () {    global$test;     Echo  $test ;}
View Code
    • Static variables, the ability to retain the value of the variable after the end of the function call, when returning to the scope, you can continue the original value, and the other will be removed after being called, so that the use of the keyword static to declare the variable, the keyword static placed before the defined variables
      Functin Test () {    static$t=0;     $t+=1;}
      static variables

Tamping the basics of PHP learning-1

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.