function function_static_var(){
static $test=1;
$test +=1;
echo $test;
}
父类和子类可以声明同名的静态变量,保存不同的值
<?php
class P{
public static $a = "parent static var";
}
class C extends P{
public static $a = "children static var";
static function test(){
echo parent::$a.'<br/>';
echo self::$a;
}
}
C::test();
?>
魔法函数 __call($fun_name,$fun_parameters) 在调用类的未定义函数时自动调用,第一个参数为函数名,第二个参数为函数参数
php单例模式
private __construct
private __clone(){}不含任何内容
private $_instance
public getInstance
final class
php6新功能
支持unicode16
支持命名空间
声明命名空间(一个文件只能有一个命名空间)
<?php
namespace Vector;
class Line{
public function draw(){
}
}
?>
使用命名空间
<?php
require_once("Vector.php");
$line = new Vector::Line();
?>
static::作用域
具有动态特性的静态方法__callStatic
<?php
class MyClass{
public static function __callStatic($name,$parameters){
echo $name.var_export($parameters,true)
}
}
MyClass::bogus('a','1',false);