Home  >  Article  >  Backend Development  >  PHP反转义问题

PHP反转义问题

WBOY
WBOYOriginal
2016-06-23 14:08:201115browse

$file="d:\1\2.pdf";

请问有什么方法,代码方法可以反转义,就是让\不起作用,否则运行之后就是错误的。


回复讨论(解决方案)

addslashes() 

addslashes() 

经测试不起作用。
$file="d:\1.pdf";
$newFile=addslashes($file);

echo之后是d:.pdf

$newFile=htmlspecialchars('d:\1.pdf');
echo $newFile;

$file = 'd:\1\2.pdf';

用双引号的话需写作
$file = "d:\\1\\2.pdf";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn