php - If url is /store/*

188
<?php
if($_SERVER['REQUEST_URI']=='/store/') {
Echo 'YES!';
}
?>

What I want it to do is echo YES! If the url is /store/hfbfifigkrigkg or if its /store/hellosister So I need something like the * who is used in other languanges as EVERYTHING

THANKS

591

Answer

Solution:

This might work:

if( preg_match("(^/store/)",$_SERVER['REQUEST_URI'])) echo "Yes!";
570

Answer

Solution:

try with strpos() and other many functions you can match like OP answers

if(strpos($_SERVER['REQUEST_URI'], '/store/') !== false) {
 echo 'YES!';
}
677

Answer

Solution:

You could try this:

if(strstr($_SERVER['REQUEST_URI'], 'store')) {
    echo 'You are now on the store page.';
}

People are also looking for solutions to the problem: php - Want to replace certain words using preg_replace

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.