Hi folks,
I have this class, and it really works for exisiting files (editing them),
but as soon as i want to create a new File with that class i get an error, that i cannot open this file.
In normal case, this file should just be created, when not found …
I run PhP under windows and apache. And i dont get it, why it doesn’t work.
[CODE]class CFile
{
private $filename;
private $handle;
public function __construct($sFileName)
{
$this->fileName = $sFileName;
//$this->filename = “test.xml”; //works, because test.xml exists
if (!$this->handle = fopen($this->filename, ‘wb+’)) throw new Exception(“Could not open File “.$this->filename);
}
public function __destruct()
{
fclose($this->handle);
}
//will be done automatically, because file is opened with w+
public function ClearFile()
{
}
public function Write($data)
{
// Write $somecontent to our opened file.
if (fwrite($this->handle, $data) === FALSE)
{
throw new Exception(‘Could not write Data $data.’);
}
}
};