1

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

My url is http://dev.proprofs.com/helpdesk/admin/admin.php?t=email

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

How to do this? Please help.

1
  • print_r($_GET) and see what you get. Or be more specific and tell us what you're really trying to accomplish Commented Oct 21, 2016 at 5:15

2 Answers 2

1

Try this if you want get file name only.

print_r(pathinfo("/Your url go here",PATHINFO_BASENAME));

The out will get file name with extension.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this, use pathinfo

<?php
$filepath  = 'http://dev.proprofs.com/helpdesk/admin/admin.php?t=email';
$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";

?>

OUTPUT :

dirname   : http://dev.proprofs.com/helpdesk/admin
basename  : admin.php?t=email
extension : php?t=email
filename  : admin

DEMO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.