标签:ati back ret htm text 实例化 实例 style static
<?php
header(‘Content-Type: text/html; charset=utf-8‘);
class Student {
public static function getStudentCount() {
var_dump($this);
return 42;
}
public function getName() {
var_dump($this);
return ‘神雕侠侣‘;
}
}
echo Student::getStudentCount(); //输出:NULL 42 /// var_dump($this)没有对象标识符
echo ‘<hr>‘;
echo Student::getName(); //输出:NULL 神雕侠侣 /// var_dump($this)没有对象标识符
echo ‘<hr>‘;
echo ‘<br>‘;
echo ‘<hr>‘;
$s = new Student;
echo $s->getName();//输出:object(Student)#1 (0) { } 神雕侠侣 ///实例化之后var_dump($this)普通方法就有对象标识符
echo ‘<br>‘; ///
echo $s->getStudentCount();//NULL 42 ///静态方法实例化之后,var_dump($this)没有标识符
echo ‘<br>‘;
标签:ati back ret htm text 实例化 实例 style static
原文地址:http://www.cnblogs.com/huodaihao/p/7071975.html