There is the next class
class Json { private $file; private $json; function __construct() { $this->$file = __DIR__ . '\..\file.json'; $this->$json = json_decode(file_get_contents($this->$file)); } public function change($namespace, $object, $value) { $this->$json->$namespace->$object->text = $value; $f = fopen($this->$file, 'w'); fputs($f, json_encode($this->$json)); fclose($f); return true; } } When calling the change function
$JSON = new Json(); $JSON->change('section', 'par', 'value'); Errors appear
Java.php on line 14 Warning: fopen ()
Warning: given to json.php on line 15
Warning: fclose (), given in json.php on line 16
How can this be fixed?