码迷,mamicode.com
首页 > 其他好文 > 详细

代码片段1

时间:2015-12-24 15:06:37      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

 1 <?php
 2 
 3 error_reporting(error_reporting(E_ALL));
 4 
 5 class A {
 6     public function init() {
 7         echo __METHOD__ . PHP_EOL;
 8     }
 9 }
10 
11 class B extends A {
12     public function test() {
13         $class = new \ReflectionMethod($this, ‘init‘);
14         $class = $class->getDeclaringClass()->name;
15 
16         if (__CLASS__ !== $class) {
17             @trigger_error(sprintf(‘Calling the %s::init() method is deprecated.‘, $class), E_USER_DEPRECATED);
18             $this->init();
19         }
20     }
21 }
22 
23 $b = new B();
24 $b->test();

 

代码片段1

标签:

原文地址:http://www.cnblogs.com/atblog/p/5072953.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!