Get only filename from url in php without any variable values which exist in the url

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I want to get filename without any $_GET variable values from a url in php?

My url is http://learner.com/learningphp.php?lid=1348

I only want to retrieve the learningphp.php from the url?

  How to do this?    Please help.

I used basename but it gives all the variable values also- learntolearn.php?lid=1348 which are in the url.

Answers

This should work:

echo basename($_SERVER[ REQUEST_URI ],  ?  . $_SERVER[ QUERY_STRING ]);

But beware of any malicious parts in your URL.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/7852296/get-only-filename-from-url-in-php-without-any-variable-values-which-exist-in-the

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils