class Portfolio extends Rest{
public $pdo;
public $lanx;
public function __construct($uid, $langx){
$this->lanx = $langx;
$db = Database::getInstance();
$this->pdo = $db->getConnection();
}
当我从Portfolio
调用函数时
Portfolio::newItem();
我怎样才能通过$uid
和$langx
到班级?
Portfolio $p = new newItem($uid, $langx);
$object = new MyClass($param1, $param2);
就像调用函数一样。还要记下该构造的"必需"和"可选"参数。
使用如下参数调用静态方法是一个更好的选择:
Portfolio::newItem($uid, $langx);
在方法定义中:
public static function newItem($uid = null, $langx = null) {
//Check Vars are set or not if not set them
//If all vars passed null and not sett in class throw exception
}