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();
  • 相关阅读:
    今天想写东东
    [BTS]Event ID: 5803 错误处理办法
    微软技术能力测试工具V0.1试用
    PMI,PMBOK,PMP,Input,Output,Update
    [BTS]5719, 5753错误处理?
    向您推荐Groove BizTalk Workspace!
    [BTS]Adapter Pack调用SAP RFC接口时间格式出错解决办法
    [BTS]BizTalk学习之Functoid篇(ID CrossReferences)
    健身减肥计划
    [BTS] Event ID 5740
  • 原文地址:https://www.cnblogs.com/aqigogogo/p/9675571.html
Copyright © 2011-2022 走看看