PHP notes 2__ variable/string/type conversion/constants/,,

Source: Internet
Author: User

<? PHP     // variable variable    $a = "OK";    $$a = "fine";    $$$a = "er";     Echo $ok ;     Echo "<br>";     Echo $fine ;? >

<?PHP//reference variable//1. Only variables have references    $a= 123; $b= &$a; Echo $b, "<br>"; $b= 321; Echo $a, "<br>"; $c= 87; $b=&$c; Echo $a, "<br>";//2. Variable b points to C, and does not bind the variable A and variable C together    unset($a);//3. Just delete the variable A, does not affect the variable B    if(isset($b))        Echo"Existed.<br>"; Else        Echo"Not existed.<br>";?>

<?PHP/** 1. Four kinds of scalars: boolean, Integer, float, String 2. Two compound: Array, Object 3. Two special: Resource, NULL*/    $a= "DSD"; Echo Var_dump($a);//output variable A's type, value, etc. information    $b= 16; $c= 016;//octal, beginning with 0    $d= 0x16; Echo $b, "<br>"; Echo $c, "<br>"; Echo $d, "<br>"; /** 1. Declaring a string must use single or double quotation marks 2. A character and multiple characters are strings (PHP) 3. The string has no length limit of 4. Double quotes can be used in single quotes, and single quotation marks can be used in double quotation marks 5. Single quotation marks are no longer used in single quotes, in double    Double quotes can no longer be used in quotation marks (unless the escape character is used) 6. The variable is parsed in double quotes, not in single quotes. 7. Escape characters can be used in double quotation marks, which can be in single quotation marks. (You can only escape the single quotation mark itself and escape the escaped symbol itself in single quotes) 8. Double quotes are powerful and single quotes are efficient, so you can use single quotes as much as possible.*/    $st= "KKK$bD ";//can parse $b    Echo $st, "<br>"; $st= ' KKK $b d ';//cannot parse $b    Echo $st, "<br>"; $st= "KKK {$b}d ";//parse the $b by curly braces, otherwise it will be $bd and cannot be resolved    Echo $st, "<br>"; $st= "KKK \ $b ={$b}d ";//Escape $ symbol    Echo $st, "<br>"; /** Delimited Symbol declaration string 1. Use <<< (less than) 2. In the starting delimiter (the custom string) must be left next to the <<< after writing the bound string, be sure to enter 3. In the end of the string delimitation, it must be To write to the head, and start with the string consistent, and directly enter 4. Use "In the beginning of the bounding symbol, will support the double quotation mark function, changed to support the single quotation mark function*/    $str=<<< ' HELLW 'FUKC"' SDFSD '"$stHELLW; Echo $str, "<br>"; /** Forced type conversion 1.setType ($a, "double");    2. $b = (int) $a; 3.intval (), Floatval (), Strval () 4.string type convert to int is only a few digits from the beginning, and if there is no number at the beginning, return 0*/    $stg= 1000; Settype($stg, "string"); $stg= (Double)$stg; Echo GetType(intval($stg)), "<br>"; $aa= "4school Hell"; $BB= 100; $CC=$aa+$BB; Var_dump($CC);//Output 145    /** Constants: 1. Constants are declared using the function define () 2. If a constant is not declared, the constant name is automatically converted to a string when it is used (very inefficient) 3. The constant name does not add the $ symbol 4. Constant names are case-sensitive (as with variables), and are used to all uppercase 5. You can use the third parameter of define (,, true/false) to determine if this constant name is case-sensitive 6. The value of a constant is only supported for scalar data type 7. You cannot use unset () to clear a constant 8. You can use defined (); Determine if a constant exists 9. Use Get_defined_constants () to get a list of all defined constants*/    Define("ROOT", "localhost"); Define("KEKE", 1234.23); EchoROOT, "<br>"; //Magic Constants    Echo __line__, "<br>";//Output Current line number ($)    $s 1= "ABC"; $s 2= "Def"; Echo"ANS:".$s 1.$s 2; //= = = Congruent, not only the content to be equal, the type must be equal//!==: non-congruent, both values and types return false, otherwise true    $a= "7ab"; $b= 7; Var_dump($a==$b);//true    Var_dump($a===$b);//false//ternary operation    $a= 1; $b= 10; $c=$a>$b? 123:321; Echo $c, "<br>"; //Call system commands? You need to check it out.    Echo' ipconfig ';?>

PHP notes 2__ variable/string/type conversion/constants/,,

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.