sqlchild sqlchild - 1 year ago 63
PHP Question

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

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

My url is


I only want to retrieve the
from the url?

How to do this? Please help.

I used basename but it gives all the variable values also-
which are in the url.

str str
Answer Source

This should work:

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

But beware of any malicious parts in your URL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download