我正在尝试将数据库行插入到对象中,我不明白这里有什么问题:(我看不到输出)。
<body>
<?php header('Content-Type: text/html; charset=utf-8');
include("dash_class.php");
mysql_connect("localhost", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("msordash");
mysql_query("SET NAMES 'utf8'");
$dashim=mysql_query("SELECT * FROM dash");
while ($row = mysql_fetch_array($dashim)) {
$dash=new dash($row["name"],$row["msg"],$row["msg_date"]);
echo $dash->name;
}
?>
</body>
班级代码:
class dash
{
public $name;
public $msg;
public $msg_date;
function __constractor($name,$msg,$msg_date){
$this->name=$name;
$this->msg=$msg;
$this->msg_date=$msg_date;}
}
?>
答案 0 :(得分:0)
什么是约束条件? :)对不起,constractor
确切是什么?
function __constractor($name,$msg,$msg_date){
应该是
__construct()
像
function __construct($name,$msg,$msg_date){