I tried to open the file with the fopen () function in PHP, and it displays a warning about refusing to open the stream: permission denied. You know that warning / error that you encounter when apache does not have sufficient privileges to open a specific file.
However, despite the warning message being displayed, my PHP script successfully opened the file and wrote a line into it. It does not make sense.
So what is it? I can put @ directly in front of fopen (), but it's still weird, and I want to know why PHP behaves this way. Is there something that I did not configure correctly?
class XMLDB {
private $file = null;
private $xml = null;
private $defs = array();
private $recs = array();
public function __construct($xmlfile) {
if (!file_exists($xmlfile)) {
die('XML file does not exist.');
}
$this -> file = $xmlfile;
$this -> xml = simplexml_load_file($this -> file);
$this -> iniVocab();
$this -> iniData();
}
... / * many private and public functions * /
public function commit() {
$xmlfile = fopen($this -> file, 'w');
$doc = new DOMDocument('1.0');
$doc -> preserveWhiteSpace = false;
$doc -> loadXML($this -> xml -> asXML());
$doc -> formatOutput = true;
fwrite($xmlfile, $doc->saveXML());
}
public function __destruct() {
$this -> commit();
}
}
EDIT: , - , . , , , , , __destruct() $this β commit() - , . .