PHP Learning with notes 1

Source: Internet
Author: User
 First line break "; Echo"
Second NewLine ';#<< <符号定义字符串的方法 #首先设置一个结束符号 #这个符号必须单独放在一个行的行首位置 #不然不能识别 #结束符必须单独一行echo << How are you doing
However, it is not good for STD; #数组 $arr 1 = Array (' You ', ' good '); echo "
$arr 1[1] "; $arr 2 = Array (0=> ' n '); echo "
$arr 2[0] "; #常量 define (' Bitch ', 111); echo "
". Bitch. $arr 2[0]; #用. To connect the string and the variable echo "
". __file__; #php提供了几个常量 This is one of the #变量的作用域 # 1) function inside the scope is the function # 2) Outside the function is the entire PHP but the user-defined function cannot be used # to use must use $heng = ' Ha '; function Hello () {global $heng; echo "
". $heng; } hello (); #动态变量 #并不是我想的那样/* $a 1 = 1; $b 1 = $a 1; echo "
". $b 1; $a 1 = 2; echo "
". $b 1;*/$chang _name =" trans "; $trans = ' can see me '; echo "
$chang _name----$ $chang _name "; #php内置好多预定义的变量 must be assigned to one of our own defined #变量才能用 reference http://php.net/manual/zh/reserved.variables.php $host = $_server[' http _host ']; echo "
$host "; #字符串运算符 #只有. This operation symbol cannot use the plus sign echo "
$a "." $b ";//13 echo"
". ("$a" + "$b");//4 #连接字符 $a. = $b; #相当于 $a = $a. $b; echo "
". $a; #逻辑运算 && = and, | | = OR, Xor is true if ($a and $b) {echo '
conditions set "; } #@ Mask Error message $worry = @ (5/0); #php函数 similar to JavaScript function HelloWorld () {echo '
Nihao"; } HelloWorld (); #引用传值 the same as C + +, the default parameter is $a 10 = 8; Function Zijia (& $a) {$a + = 10; } Zijia ($a 10); echo "
$a 10 "; #支持变量函数 the so-called variable function is to call the function using the variable name $func = "HelloWorld"; $func (); #对函数的引用的就是对函数返回值的应用 function h () {return "HelloWorld"; } $aaaa = h (); echo "
". $aaaa; #声明一个引用类型的函数 #发现引用函数不能直接返回一个常量 #所以 can foresee that it returns a variable #地址 instead of copying a value directly to the Received variable function &hh () {$str = "HelloWorld"; return $str; } $bbbb = &hh (); echo "
$BBBB "; #当引用结束的时候可以通过unset () to dereference #php命名规范 #类名使用驼峰法 #类属性前面就前缀m #类的方法命名 general rule prefixes such as the is Get Set #变量使用小驼峰命名 #引用变量要有前缀r The global variable has the G prefix static variable using the s prefix #变量分割使用_ #方法, the class does not use the _ but the case is able to #php流程控制语句 and other languages as much as a foreach () #类似于java的增强for循环 #在一个 Complex PHP pages may contain multiple conditional statements, and looping statements #和函数 using {} can be cumbersome, so PHP provides another way to use ":" #代替 "{" and "end*" instead of "}" #支持endif, ENDWHILE,ENDFOR,ENDREAC H,endswitch $s = 1; echo "
"; while ($s + + <): echo "I love you.
"; Endwhile; ?>
  • 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.