The execution is successful like this:
<?php
$filename="test.txt";
file_put_contents($filename, "nihao");
?>
But this will fail:
<?php
$filename="test.txt";
file_put_contents($filename, "ni&hao");
?>
Please give me some advice. There is just an extra and symbol. How should I deal with this?
迷茫2017-05-16 13:15:03
"ni&hao" Add the escape character '&' before special characters or change the double quotes to single quotes.
怪我咯2017-05-16 13:15:03
<?php
$filename="test.txt";
file_put_contents($filename, json_encode("ni&hao"));
?>