I want to check which URL someone is currently on. For example:
if(url=index.php?p=contact) {
echo the code i want to run,
}
else {
do nothing
}
So basically, I want to run a block of code when the user is on index.php?p=contact
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you need to check the complete path, see Gumbo’s answer. If
index.phpis only accessible by navigating to that name directly (that is, you know ifindex.phpis being executed the user must’ve gone toindex.php, and you’re not using something like URL rewriting), it probably makes much more sense to just check:within
index.php. If the condition is being reached,index.phpis executing and clearly that’s the page the user is on