bonaca bonaca - 1 month ago 5
PHP Question

Get file name if it's not part of url

url:

localhost/story/


current file is index.php

Is there a way to get file name (index.php) in php, if it's not part of url.

basename(__FILE__)
doesn't work because result is
contact.php
probably because
contact.php
is included at the beginning of
index.php
.

Answer
echo basename($_SERVER['PHP_SELF']);
Comments