I use file_get_contents()
& file_put_contents()
to load and save a .css
file. After saving the loaded file the file_put_contents()
function will escape the quotes, how can this be prevented.
$file = 'pathto/base.css';
$ta = $file_get_contents($file);// load
<textarea name="editor"><?php echo $ta;?></textarea>
// press submit button here
file_put_contents($file, $_POST['editor']);// save
// new css code will be something like this
.row:after{
content:/"/";// not what we need
}
Stripslashes is probably what you're looking for. Certain PHP installations will automagically escape strings for you by adding slashes. This should reverse that.
Check out Magic Quotes
Most likely you have Magic Quotes turned on.
So just turn it off in php.ini
and restart PHP.
To strip the slashes:
file_put_contents($file, stripslashes($_POST['editor']));