Php learning Note 1
The first line feed "; echo'
The second newline '; # <
<符号定义字符串的方法 #首先设置一个结束符号 #这个符号必须单独放在一个行的行首位置 #不然不能识别 #结束符必须单独一行echo <<
Hi!
However, std is not good; # array $ arr1 = array ('you', 'hao'); echo"
$ Arr1 [1] "; $ arr2 = array (0 => 'n'); echo"
$ Arr2 [0] "; # constant define ('bitch', 111); echo"
". Bitch. $ arr2 [0]; # Use. to connect strings and variable echo"
". _ FILE __; # php provides several constants. this is one of them. # The scope of the variable #1) the internal scope of the function is the function #2) the function is external to php, but the user-defined function cannot be used # to use it, you must use $ heng = 'ha'; function hello () {global $ heng; echo"
". $ Heng;} hello (); # dynamic variable # not what I think/* $ a1 = 1; $ b1 = $ a1; echo"
". $ B1; $ a1 = 2; echo"
". $ B1; */$ chang_name =" trans "; $ trans = 'You can see me'; echo"
$ Chang_name ---- $ chang_name "; # php built-in many pre-defined variables must be assigned to a defined # variables in order to use the reference http://php.net/manual/zh/reserved.variables.php $ host = $ _ SERVER ['http _ host']; echo"
$ Host "; # string operator # only. this operator number cannot use the plus sign echo"
$ A "." $ B "; // 13 echo"
". (" $ A "+" $ B "); // 4 # connection character $ a. = $ B; # equivalent to $ a = $ a. $ B; echo"
". $ A; # logical operation & = and, | = or. if xor is true or false, it is true if ($ a and $ B) {echo"
The condition is true. ";}#@ shield error message $ worry =@ (5/0); # The php function is similar to the javascript function HelloWorld () {echo"
Nihao";} HelloWorld (); # The default parameter for passing reference values is the same as that for c ++. $ a10 = 8; function zijia (& $) {$ a + = 10;} zijia ($ a10); echo"
$ A10 "; # variable functions are called using variable names to call functions $ func =" HelloWorld "; $ func (); # function h () {return "HelloWorld" ;}$ aaaa = h (); echo"
". $ Aaaa; # declare a function of the reference type # It is found that the referenced function cannot directly return a constant # so it is foreseeable that it returns a variable # address instead of copying a value and directly copying it to the received variable function & hh () {$ str = "HelloWorld"; return $ str ;}$ bbbb = & hh (); echo"
$ Bbbb "; # when the reference ends, you can use unset () to remove reference # php naming convention # class name using the camper method # class attribute prefix m # class method naming General rule prefix such as IS Get Set # variable using small camper name # Reference variables must have prefix r global variables and g prefix static variables use s prefix # variable segmentation use the _ # method, the class is case-insensitive instead of _. # A foreach () is added to the php process control statement like other languages () # enhancement for loop similar to java # A complicated php page may contain multiple conditional statements, loop statement # and function Use {} will be very troublesome, so php provides another way to use ":" # Replace "{", use "end *" instead of "}" # endif, endwhile, endfor, endreach, endswitch $ s = 1; echo"
"; While ($ s ++ <10): echo" I love you
"; Endwhile;?>