首页 > 学院 > 开发设计 > 正文

类实例化对象可以访问静态(static)方法,但是不能访问静态属性。

2019-11-08 01:17:02
字体:
来源:转载
供稿:网友
<?phpini_set('display_error', true);error_reporting(E_ALL); class Dog {     public static $name 'wangwang';     static function say($data) {        echo $data;    }}$myDog new Dog(); $myDog->say('123456'); // 输出 123456 echo $myDog->name; // 发出Notice信息: Undefined PRoperty: Dog::$name in ... ?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表