How to replace the obtained address in php

autoload
Release: 2023-03-08 20:10:02
Original
2231 people have browsed it

正斜杠,又称左斜杠,符号是"/",英文是forward slash。

反斜杠,也称右斜杠,符号是"\",英文是backward slash。

1.首先获取路径:

<?php
 $a=__DIR__."\\";
  echo $a."<br>";
Copy after login

输出结果如下:

D:\phpStudy\PHPTutorial\WWW\blog\
Copy after login

2.利用str_replace()进行替换

//承接上述代码
    $a=str_replace("\\","/",$a);
    echo $a;
Copy after login

输出结果如下:

D:/phpStudy/PHPTutorial/WWW/blog/
Copy after login

推荐: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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!