I need to pass parent class variable in function which is being called in child class's method.
Please see the code!
class CsBuilder {
protected static $mysqli = 0;
private function connect() {
// make connection
$mysqli = new mysqli(data);
self::$mysqli = $mysqli;
}
public function initialise() {
$this->connect();
// other stuff
}
}
class App extends CsBuilder {
public function test() {
// parent::$mysqli is accessable here!
function innerFuntion() {
$query = 'some query';
// parent::$mysqli->query($query);
// how to access parent::$mysqli here?
}
innerFuntion();
}
}
$builder = new CsBuilder();
$builder->initialise();
$app = new App();
$app->test();
I got follwing error:
PHP Fatal error: Class 'parent' not found...
Any ideas?
Thanks