首页 > Web开发 > 详细

php

时间:2016-08-01 17:45:48      阅读:277      评论:0      收藏:0      [点我收藏+]

<?php
class A
{
    function foo()
    {
        if (isset($this)) {
            echo ‘$this is defined (‘;
            echo get_class($this);
            echo ") ";
        } else {
            echo "$this is not defined. ";
        }
    }
}

class B
{
    function bar()
    {
        A::foo();
    }
}

$a = new A();
$a->foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>

以上例程会输出:

$this is defined (a)
$this is not defined.
$this is defined (b)
$this is not defined.

php

原文:http://www.cnblogs.com/wxdzbc/p/5726446.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!