0

例如这个$name = pulic $wherever;,所以我可以打电话,例如,wherever->wherever;

这样我就不必每次添加变量时都输入这个名称

// If it's going to need the database, then it's 
// probably smart to require it before we start.
require_once('database.php');

class Logs extends DatabaseObject {

protected static $table_name="logs";
protected static $db_fields = array('id', 'username', 'ip', 'time', 'page');



public $id;
public $username;
public $ip;
public $time;
public $page;
4

1 回答 1

0

您可以使用extract()

extract( $db_fields ); 

那么你就不需要一一声明了。

class Logs extends DatabaseObject {

protected static $table_name="logs";
protected static $db_fields = array('id', 'username', 'ip', 'time', 'page');

extract( $db_fields ); 
于 2012-05-21T20:01:41.400 回答