Home > Article > Backend Development > How to replace the obtained address in php
正斜杠,又称左斜杠,符号是"/",英文是forward slash。
反斜杠,也称右斜杠,符号是"\",英文是backward slash。
1.首先获取路径:
<?php $a=__DIR__."\\"; echo $a."<br>";
输出结果如下:
D:\phpStudy\PHPTutorial\WWW\blog\
2.利用str_replace()
进行替换
//承接上述代码 $a=str_replace("\\","/",$a); echo $a;
输出结果如下:
D:/phpStudy/PHPTutorial/WWW/blog/
The above is the detailed content of How to replace the obtained address in php. For more information, please follow other related articles on the PHP Chinese website!