PHP变量以$
字符串模板 : $temp = “Hello , {$var1} !”;
if语法:(注:是 elseif 不是else if)
if(true){
}elseif(false){
}else{
}
while语法:
while(true){
}
数组语法:
array(key=>value,key=>value)
[key=>value,key=>value] //映射类数组
[value1,value2] //顺序类数组
count($array) //返回数组长度
数组迭代:
foreach($array as $key => $value){
}
foreach ($array as $value){
}
函数:
function($variable){
return $value
}
模块: 通过require引入某个文件 通过use 引入命名空间
require “another.php”
use “/Robin/luo/Another”
类:
class Another {
public $property
public function __construct($property){
this->property = $property;
}
public function func($param){
return $value;
}
public static function func1(){
}
}
$object = new Another();
$object1 = new Another(1);
$object->property = 1;
$object->func(1);
Another::func1();
命名空间:通过namespace 定义 用\进行解析不是java的.
namespace Robin;
\Robin\luo::reading();