Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:Replace"/&引用;加上\&引用;在URL中_Php_Str Replace - Fatal编程技术网

PHP:Replace"/&引用;加上\&引用;在URL中

PHP:Replace"/&引用;加上\&引用;在URL中,php,str-replace,Php,Str Replace,如何在这样的PHP字符串中替换“/ C:\files\mybundle/files/example.pdf 我的期望输出: C:\files\mybundle\files\example.pdf 这不起作用: $urlFormatted = str_replace('/', '\', $string) 编辑:) 您需要按照以下方式进行操作:- $urlFormatted = str_replace('/', '\\', $string) 也 $urlFormatted = str

如何在这样的PHP字符串中替换“/

C:\files\mybundle/files/example.pdf
我的期望输出:

C:\files\mybundle\files\example.pdf
这不起作用:

$urlFormatted = str_replace('/', '\', $string) 
编辑:)


您需要按照以下方式进行操作:-

 $urlFormatted = str_replace('/', '\\', $string) 

 $urlFormatted = str_replace('/', '\\', $string) 
$urlFormatted = preg_replace('[/]', '\\', $data) ;