简体   繁体   中英

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

I tried with $PHP_SELF but the result is:

image/read_my_file.php

And I want to get only the file name of PHP in the url which is loaded.

Thank you, regards

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

check this link for more info: PHP Manual

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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