php - file_put_contents包含&符号的时候执行失败怎么破?
滿天的星座
滿天的星座 2017-05-16 13:13:03
0
3
705

这样子执行成功:
<?php
$filename="test.txt";
file_put_contents($filename, "nihao");
?>

但这样会失败:
<?php
$filename="test.txt";
file_put_contents($filename, "ni&hao");
?>

求指点,只是多了一个and符号,请问这样要怎么处理?

滿天的星座
滿天的星座

reply all(3)
迷茫

"ni&hao" Add the escape character '&' before special characters or change the double quotes to single quotes.

迷茫

Is it possible? I have tested both methods and both are fine.

刘奇
<?php
$filename="test.txt";
file_put_contents($filename, json_encode("ni&hao"));
?>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!