例如,我如何得到output。map

from

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

使用PHP吗?


当前回答

试试这个:

echo basename($_SERVER["SCRIPT_FILENAME"], '.php') 

其他回答

为了从URI中获得确切的文件名,我将使用以下方法:

<?php
    $file1 =basename("http://localhost/eFEIS/agency_application_form.php?formid=1&task=edit") ;

    //basename($_SERVER['REQUEST_URI']); // Or use this to get the URI dynamically.

    echo $basename = substr($file1, 0, strpos($file1, '?'));
?>

试试这个:

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

您正在寻找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"
?>