• php的魔术常量以及类的模式方法


    魔术方法
    class
    A { const PI = 3.14; static $type = 'type1'; public $a1='a1'; public function fun1(){ var_dump('我是fun1'); } public $a2='a2'; protected function fun2(){ var_dump('我是fun1'); } public $a3='a3'; private function fun3(){ var_dump('我是fun1'); } final function fun4(){ //最终方法 子级不可覆盖 } function __construct() //构造函数 实例化对象时调用 { var_dump(self::PI); } function __get($name)//获取对象不存在的属性是执行 { // TODO: Implement __get() method. } function __set($name, $value)//设置对象不存在的属性是执行 { // TODO: Implement __set() method. } function __isset($name)// { // TODO: Implement __isset() method. } function __unset($name) { // TODO: Implement __unset() method. } function __call($name, $arguments) //调用对象不存在的方法时调用 { // TODO: Implement __call() method. } function __clone() //克隆对象时调用 { // TODO: Implement __clone() method. } function __destruct()//析构函数 { // TODO: Implement __destruct() method. } function __sleep() //对象序列化时调用 { // TODO: Implement __sleep() method. return arr('a',b); } function __wakeup()//对象反序列化时调用 { // TODO: Implement __wakeup() method. } function __toString()//对象当做字符串使用时 { // TODO: Implement __toString() method. return 'str'; } function __invoke() //对象当做方式是调用 { // TODO: Implement __invoke() method. } } $a=new A();

    魔术常量

    var_dump(__FILE__) ;
    var_dump(__DIR__) ;
    var_dump(__LINE__) ;
    function fn(){
        echo __METHOD__;
        echo __CLASS__;
    }
    fn();
  • 相关阅读:
    说实话,mycat就是垃圾,不再更新
    深入理解并发/并行,阻塞/非阻塞,同步/异步
    转载:PHP 协程实现
    转载:异步、并发、协程原理
    第四章总结
    第三节 需要异常
    [第四章] 测试依赖性和异常
    第三章总结
    第三节 MVC应用程序架构和测试
    第二节 PHPUnit测试的剖析
  • 原文地址:https://www.cnblogs.com/aqigogogo/p/9675571.html
Copyright © 2020-2023  润新知