Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nosajhpled/3de457ccfdc4576c79ff346b5c5f554d to your computer and use it in GitHub Desktop.
Save nosajhpled/3de457ccfdc4576c79ff346b5c5f554d to your computer and use it in GitHub Desktop.
This handy line of PHP code will retun the script name only without the full path
preg_split('/\//', $_SERVER['SCRIPT_NAME'])[count(preg_split('/\//', $_SERVER['SCRIPT_NAME']))-1]
Example:
http:\\localhost\test.php
Would become:
test.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment