tags:

views:

46

answers:

2
<?php


$file = fopen("configuration.conf","w+");
$settings['LogEnabled'] = "true";
$settings['Pass'] = "pass";
$settings['ShowWarning'] = "true";
fwrite($file,serialize($settings));


$path = "configuration.conf";
$file2 = file_get_contents($path);
$settings2=unserialize($file2);
echo($settings2['LogsEnabled']);

?>

It ought to show "true" when run. Whats wrong?

I tried fread and fopen for $file2, but neither work.

EDIT: It does not throw an error.

The file has permissions 0740

+3  A: 

Flush (and preferably close the file), before reading its contents.

/* Write stuff to $file */
fflush($file);
fclose($file);
/* Read stuff from file */
gnud
+4  A: 

Not sure if it matters, but you have 'LogEnabled' in the serialize section and 'Log**s**Enabled' in the unserialize section.

Could that 's' be throwing you off?

Eric
Didn't even notice that. Thanks for the help!
Cyclone
Hehe. The simpler solution, that I completely overlooked :P He should still close the file before reading, tho.
gnud