Aloha 🙂
Is it possible to have a constructor with a reference as a parameter and then use that from another class?
Class 1 named ABC
function __construct( $table, $key, &$db ){
$this->_tbl = $table;
$this->_tbl_key = $key;
$this->_db =& $db;
$this->_pkey = $key;
}
Next I want to use ABC in XYZ. Like so:
$ABC= new ABC("dummytable", "id");
But obviously this is missing a paramater and when I do enter a paramater it returns an error about reference..
How can I solve this?
Thanks 🙂
If
$dbis object, then don’t pass it as reference. If the parameter is optional, then give it a default value.