gabrieltong 发表于 2013-2-7 02:00:39

php学习笔记一

self::和$this->的区别
self::可以访问实例变量和类变量,$this->只可以访问实例变量
函数可以定义静态变量
function function_static_var(){    static $test=1;    $test +=1;    echo $test;} 父类和子类可以声明同名的静态变量,保存不同的值
<?phpclass 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
支持命名空间
声明命名空间(一个文件只能有一个命名空间)
<?phpnamespace Vector;class Line{public function draw(){}}?>使用命名空间
<?phprequire_once("Vector.php");$line = new Vector::Line();?>static::作用域
具有动态特性的静态方法__callStatic
<?phpclass MyClass{public static function __callStatic($name,$parameters){echo $name.var_export($parameters,true)}}MyClass::bogus('a','1',false); 修改过的三目运算符
$input = $input?$input:'default';$input = $input?:'default'; 
SqlObjectStorage
 
标准php库spl
ArrayAccess

[*]offsetExists($offset)
[*]offsetSet($offset,$value)
[*]offsetGet($offset)
[*]offsetUnset($offset)
 
Countable

[*]count
 
 
 
 
 
 
 
页: [1]
查看完整版本: php学习笔记一