Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php write file converts single quotes to double quotes

Tags:

php

My code is like this

$fp = fopen('text.php', 'w');
fwrite($fp, $_POST['code']);
fclose($fp);

But if $_POST['code'] has single quotes (') output will be 2 single quotes for example:
if input is 'test'

if we open text.php output will

''test''

i also tried file_put_contents() but same result How can i solve this problem?

edit

for $_POST['code']; exit() also i am getting same output

like image 763
Harish U Warrier Avatar asked Nov 01 '22 02:11

Harish U Warrier


1 Answers

Try re-installing your lamp server.

like image 179
shabeer Avatar answered Nov 15 '22 04:11

shabeer