Jump to content

Problem with fwrite()


Perfidus

Recommended Posts

I'm not doing anything special, I have just copied the code from the php manual and substituted the 'a' in fwrite for 'w' all I'm trying to do is to write write to a xml file.

The problem is that I can  only write 3 characters, in this case: "Com"

$filename = 'myfolder/data.xml';
$somecontent = 'Come on write some stuff';	
if (is_writable($filename)) 
{	
if (!$handle = fopen($filename, 'w'))
    {
	 echo "Problem opening file";
	 exit;
}
if (fwrite($handle, $somecontent) === FALSE) 
    {
	echo "Problem writing to file";
	exit;
}	
echo "The file have been written";	
fclose($handle);	
    } 
else 
{
	echo "Impossible to read the file";
}

Link to comment
https://forums.phpfreaks.com/topic/182960-problem-with-fwrite/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.