<?
class Usename
{
//定义属性
private $name;
//定义构造函数
function __construct( $name )
{
$this -> name = $name; //第一次使用this指针
}
//定义析构函数
function _destruct(){}
//打印用户名函数
function printName()
{
print($this -> name ); //第二次使用this指针
}
}
$nameObject0 = new Usename("dreamercc"); //实例化对象
$nameObject0 -> printName();
?>
自己感悟:$this指针就是调用对象,这里调用的对象为$nameObject0。