I have been with this problem for a little more than a day, I checked the possible similarity of my question with others, but the truth, none of them worked for me.
I'm having the following error in PHP:
Fatal error: Uncaught Error: Call to a member function get() on null
File Url.php , line 28.
Url.php :
<?php
class Url extends App {
private $db;
private static $alias = null;
private static $mcpe_list = null;
private static $url2 = null;
private static $clicks = 0;
private static $name = null;
private static $password = null;
public function __construct() {
$this->db = json_decode(file_get_contents('/../' . $this->config->get('DB_PATH')), true);
}
}
App.php :
<?php
class App {
protected $error;
protected $url;
protected $config;
const CFG_PATH = 'private/config.json';
const VAL_ERRORS = [400, 401, 403, 404, 500];
public function __construct() {
$this->error = new Error();
$this->url = new Url();
$this->config = new Config(self::CFG_PATH);
}
}
The error, $this->config->get('DB_PATH')
occurs in the constructor of class Url.
Instances are created in the App class and as Url extends App, the protected properties are inherited.
Thanks for your answers.