Home  >  Article  >  Backend Development  >  How to replace the obtained address in php

How to replace the obtained address in php

autoload
autoloadOriginal
2021-03-18 11:45:202292browse

正斜杠,又称左斜杠,符号是"/",英文是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/

推荐:php视频教程 php教程

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!

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