だから私は2つのクラスがあります:
テーブルクラス
<?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
)
代わりに、次を返します。
Array (
[username] =>
[password] =>
[email] =>
[table] => user
)
変数がスーパークラスにバインドされていない理由を教えてくれる親切な人がいますか?????
here によると、動作するはずです: