shiv pratap shiv pratap - 3 months ago 14
PHP Question

Get filename and variable name from url in php which exist in the url

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

My url is

I only want to retrieve the admin.php?t=email from the url?

How to do this? Please help.


Try this, use pathinfo

$filepath  = '';
$path_parts = pathinfo($filepath);

echo "dirname   : ".$path_parts['dirname']."\n";
echo "basename  : ".$path_parts['basename']."\n";
echo "extension : ".$path_parts['extension']."\n";
echo "filename  : ".$path_parts['filename']."\n";



dirname   :
basename  : admin.php?t=email
extension : php?t=email
filename  : admin