请看以下代码,请大侠们帮忙,程序运行结果为什么只有“没有显示上一行的内容”
<?$b = new book("上帝原谅我");
$b->showTitle();
class book
{
var $title;
function book($t)
{
$title = $t;
}
function showTitle()
{
echo "$title";
echo "没有显示上一行的内容";
}
}
?>
<?$b = new book("上帝原谅我");
$b->showTitle();
class book
{
var $title;
function book($t)
{
$title = $t;
}
function showTitle()
{
echo "$title";
echo "没有显示上一行的内容";
}
}
?>
<? $b = new book("上帝原谅我");
$b->showTitle();
class book
{
var $title; function book($t)
{
$this->title = $t;
} function showTitle()
{
echo $this->title;
echo "没有显示上一行的内容";
}
}
?>
{
$this->title = $t;
}
PHP对象构造函数是 function __construct()
{
$this->title = $t;
}
php5的构造函数是__construct().php4的不是.在类内部引用类属性或方法要用$this.