从php

时间:2017-01-01 02:16:54

标签: php

的.htaccess

  

RewriteRule ^([A-Za-z0-9 - ] +)/([a-zA-Z0-9 _-] +)$ get / get-post.php?link = $ 1&amp; h_link = $ 2 < / p>

在网址中显示的内容是

  

http://example.com/post-name/sub-name

现在我想获取文件的名称(使用PHP),你可以看到get-post.php

我尝试过使用basename()功能,但它给我的全部是网址中的子名称部分。

1 个答案:

答案 0 :(得分:0)

尝试

<?php
$path = "/testweb/home.php";

//Show filename with file extension
echo basename($path) ."<br/>";

//Show filename without file extension
echo basename($path,".php");
?> 

请参阅http://www.w3schools.com/Php/func_filesystem_basename.asp