日期:2014-05-17 浏览次数:20688 次
function say()
{
echo "用户:".$this->name."<br>学号:".$this->num."<br>年龄:".$this->age."<br>联系电话:".$this->tel;//这里连号没用
}
}//内没关闭,少大括号
$p=new Message("张三",200440132,21,63886666);
------解决方案--------------------
echo "用户:".$this->name."<br>学号:".$this->num."<br>年龄:".$this->age."<br>联系电话:".$this->tel;
注意连接符
------解决方案--------------------
<?php
class Message
{
private $name;
private $num;
private $age;
private $tel;
function __construct($name,$num,$age,$tel)
{
$this->name=$name;
$this->num=$num;
$this->age=$age;
$this->tel=$tel;
}
function say()
{
echo "用户:".$this->name."<br>学号:".$this->num."<br>年龄:".$this->age."<br>联系电话:".$this->tel;//变量与字符串的连接符用.
}
}//少写了一个}
$p=new Message("张三",200440132,21,63886666);
$p->say();
?>
------解决方案--------------------
感谢半天不结贴的