zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    94. Binary Tree Inorder Traversal
    101. Symmetric Tree
    38. Count and Say
    28. Implement strStr()
    实训团队心得(1)
    探索性测试入门
    LC.278. First Bad Version
    Search in Unknown Sized Sorted Array
    LC.88. Merge Sorted Array
    LC.283.Move Zeroes
  • 原文地址:https://www.cnblogs.com/aqigogogo/p/9675571.html
Copyright © 2011-2022 走看看