所以我有两个课程:
表类
<?php
class table {
protected $id = null;
protected $table = null;
function __construct() {
}
function bind($data) {
// print_r($data);
foreach ($data as $key=>$value) {
$this->key = $value;
// echo $key."--".$value;
// echo $this->$key;
}
}
}
?>
用户类
<?php
class user extends table
{
var $username = null;
var $password = null;
var $email = null;
var $table = "user";
}
?>
我也有一个索引引导程序......
<?php
include('table.class.php');
include('user.class.php');
$user = new user();
$data = array("username" => "Forest", "password" => "*****", "email"=>"foo@bar.com");
$user->bind($data);
$classVars = get_class_vars(get_class($user));
print_r($classVars);
?>
它应该返回:
Array(
[username] => Forest,
[password] => *******,
[email]=>foo@bar.com
[table] => user
)
INSTEAD 它返回:
Array (
[username] =>
[password] =>
[email] =>
[table] => user
)
有人可以告诉我为什么变量没有绑定到超类吗??????
根据这里它应该工作: