相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動到新位置)
- dirname(__FILE__)的含義和應(yīng)用說明
- thinkPHP5框架實(shí)現(xiàn)分頁查詢功能的方法示例
- PHP中單雙號與變量
- PHP獲得當(dāng)日零點(diǎn)時間戳的方法分析
- Laravel ORM對Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時進(jìn)度條顯示的實(shí)現(xiàn)
PHP靜態(tài)延遲綁定和普通靜態(tài)效率的對比
PHP靜態(tài)延遲綁定和普通靜態(tài)效率的對比
只是一個簡單的小實(shí)驗(yàn),對比了下 延遲綁定 和 非延遲的效率
延遲綁定主要就是使用 static 關(guān)鍵字來替代原來的 self ,但功能非常強(qiáng)大了
實(shí)驗(yàn)代碼:
class A { protected static $cc1 = array('a1', 'b', 'c', 'd'); protected static $cc2 = array('a2', 'b', 'c', 'd'); protected static $cc3 = array('a3', 'b', 'c', 'd'); protected static $cc4 = array('a4', 'b', 'c', 'd'); protected static $cc5 = array('a5', 'b', 'c', 'd'); public static function n1() { return static::$cc1; } public static function n2() { return static::$cc2; } public static function n3() { return static::$cc3; } public static function n4() { return static::$cc4; } public static function n5() { return static::$cc5; } } class C extends A { } class B { protected static $cc1 = array('a1', 'b', 'c', 'd'); protected static $cc2 = array('a2', 'b', 'c', 'd'); protected static $cc3 = array('a3', 'b', 'c', 'd'); protected static $cc4 = array('a4', 'b', 'c', 'd'); protected static $cc5 = array('a5', 'b', 'c', 'd'); public static function n1() { return self::$cc1; } public static function n2() { return self::$cc2; } public static function n3() { return self::$cc3; } public static function n4() { return self::$cc4; } public static function n5() { return self::$cc5; } }