0

I would like to know how to do an 'if requested URL like' statement. For example, I currently have the following code, but I want to the base, icon and logo applied on all locations after route=checkout/

What is the wildcard value? Am I on the right lines?

<?php
if($_SERVER["REQUEST_URI"]=="/index.php?route=checkout/checkout")
$base='https://domain.co.uk/>';
$icon='/image/data/favicon.png';
$logo='/image/data/logo.png';
?>
1
  • 1
    Your question is a bit unclear. Can you reword it? Commented Dec 15, 2011 at 20:12

1 Answer 1

2

Strpos is perhaps what you want?

if (strpos($_SERVER['REQUEST_URI'], '/index.php?route=checkout') !== false) {
// Do your stuff here.
}
Sign up to request clarification or add additional context in comments.

2 Comments

That's great, thanks! What if I want multiple values such as '/index.php?route=checkout' '/index.php?route=account' '/index.php?route=affiliate' How could I do that?
You could use a regular expression to do the matching (preg_match(/(checkout|affiliate|account)/, $_SERVER['REQUEST_URI']) (note: I didn't test that), or you could parse out the uri bits using parse_url: php.net/manual/en/function.parse-url.php and then check the query parameters on their own.

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.