用双斜杠替换单斜杠 [英] replace single slash with double slash

查看:166
本文介绍了用双斜杠替换单斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在文件

路径中加倍斜杠时遇到了一些麻烦。我想要做的是非常类似于下面的代码:


< ;?

$ var =" \\wusais\Intranets \ Intranets\fpdb\pdf\weinig\0050 5882.pdf" ;;

$ new = preg_replace(" \\"," \\\ "," $ var");

?>


上面的代码会产生以下错误:


解析错误:解析错误,c:\ Inetpub \ www.root中的意外T_VARIABLE
第12行
\ pages \ place.php


最后,$ new需要:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ weinig \\\\00505882.pdf

但是替换斜线似乎很困难。


任何帮助都会非常感激

I am having a bit of trouble trying to double up on slashes in a file
path. What I am trying to do is very similar to the code below:

<?
$var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\0050 5882.pdf";
$new = preg_replace("\\", "\\\", "$var");
?>

Code above produces the following error:

Parse error: parse error, unexpected T_VARIABLE in c:\Inetpub\wwwroot
\pages\replace.php on line 12

In the end, $new needs to be: \\\\wusais\\Intranets\\Intranets\\fpdb\
\pdf\\weinig\\00505882.pdf

but it seems to be very difficult replacing slashes.

Any help would be greatly appreciated

推荐答案

var =" \\wusais\Intranets\Intran ets\fpdb\pdf\weinig\0050 5882.pdf" ;;
var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\0050 5882.pdf";


new = preg_replace(" \\"," \ \\,"
new = preg_replace("\\", "\\\", "


var");

?>


以上代码生成以下错误:


解析错误:解析错误,c:\ Inetpub \ www.root中的意外T_VARIABLE

\ pages \replace.php on第12行


最后,
var");
?>

Code above produces the following error:

Parse error: parse error, unexpected T_VARIABLE in c:\Inetpub\wwwroot
\pages\replace.php on line 12

In the end,


这篇关于用双斜杠替换单斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆