例如,我如何得到output。map

from

F:\程序文件\SSH通信安全\SSH安全Shell\Output.map

使用PHP吗?


当前回答

SplFileInfo:

SplFileInfo类提供了一个高级的面向对象 到单个文件的信息的接口。

裁判:http://php.net/manual/en/splfileinfo.getfilename.php

$info = new SplFileInfo('/path/to/foo.txt');
var_dump($info->getFilename());

或/ p:管柱(7)“foo。txt”

其他回答

您正在寻找basename。

下面的例子来自PHP手册:

<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);         // $file is set to "index.php"
$file = basename($path, ".php"); // $file is set to "index"
?>

您可以使用basename()函数。

SplFileInfo:

SplFileInfo类提供了一个高级的面向对象 到单个文件的信息的接口。

裁判:http://php.net/manual/en/splfileinfo.getfilename.php

$info = new SplFileInfo('/path/to/foo.txt');
var_dump($info->getFilename());

或/ p:管柱(7)“foo。txt”

$image_path = "F:\Program Files\SSH Communications Security\SSH Secure Shell\Output.map";
$arr = explode('\\',$image_path);
$name = end($arr);
$filename = basename($path);