Php fwrite不写反斜杠
我在输入带有反斜杠的文本时遇到问题。这是因为从以前的表单中获取了一条POST消息(消息)。这个问题还有解决的办法吗?我的魔法报价已启用Php fwrite不写反斜杠,php,fwrite,backslash,Php,Fwrite,Backslash,我在输入带有反斜杠的文本时遇到问题。这是因为从以前的表单中获取了一条POST消息(消息)。这个问题还有解决的办法吗?我的魔法报价已启用 <?php $filename = 'test.txt'; $somecontent = $_POST['message']; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we'
<?php
$filename = 'test.txt';
$somecontent = $_POST['message'];
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
预期:
Message = Jo\hn, POST result : Jo\\hn, Output : Jo\\hn
输出必须与POST结果相同,而不是原始消息本身 结果和预期的结果似乎是一样的,有什么问题吗?“我的魔法引号被启用了。”sry我的意思是结果:Message=Jo\hn,POST=Jo\\hn,Output:Jo\hn预期的是:Jo\hn,Jo\\hn,Jo\\hn输出应该与POST Message相同,而不是原始的Message。你能用你想要的结果编辑问题吗?像这样有点不清楚。。。。
Message = Jo\hn, POST result : Jo\\hn, Output : Jo\\hn