简体   繁体   English

PHP检测从URL加载文件名

[英]Php detect file name load from url

I want to detect the name of a file when loading my url, for example this: 我想在加载网址时检测文件名,例如:

http://www.test.com/image/read_my_file.php

I want to know the name of the file loaded using PHP, in this case it´s read_my_fyle.php 我想知道使用PHP加载的文件的名称,在这种情况下为read_my_fyle.php

I tried with $PHP_SELF but the result is: 我尝试使用$ PHP_SELF,但结果是:

image/read_my_file.php

And I want to get only the file name of PHP in the url which is loaded. 我只想在加载的URL中获取PHP的文件名。

Thank you, regards 谢谢,问候

try this: basename($_SERVER['PHP_SELF']); 试试这个: basename($_SERVER['PHP_SELF']);

check this link for more info: PHP Manual 检查此链接以获取更多信息: PHP手册

您可以使用以下命令: $_SERVER['SCRIPT_FILENAME']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM