首页 > 其他 > 详细

代码片段1

时间:2015-12-24 15:03:22      阅读:163      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!