E
E
Ex1st2020-10-01 22:07:57
PHP
Ex1st, 2020-10-01 22:07:57

How to check if a user is on a specific url using php?

Friends, hello.

I have a task to call a popup when I am on a certain page. I went through the documentation, but did not understand how to organize a check for a yurl? And whether I write something wrong, but I did not find the answer to the question in Google. It's like everyone knows it but me.

I decided to call the popup like this:

if (проверка нахождения юзера на определённом юрл) {
require ("show-modal.php");
}

I start all this business on Bitrix

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Gnevyshev, 2020-10-01
@Ex1st

Generally - depends on CMS.
But there are general options.
For example, look into the $_SERVER super-global array AND look at something like
echo '<pre>'; print_r($_SERVER); echo '</pre>';
$_SERVER['REQUEST_URI']

P
PetrPo, 2020-10-01
@PetrPo

It's like everyone knows it but me.

And there is)
CSite::InDir();
$APPLICATION->GetCurDir();
$APPLICATION->GetCurPage();

Google, choose what suits you best

A
alekssamos, 2020-10-02
@alekssamos

Dudes, isn't it easier to check the URL through javascript on the client and do this window already there?<script>

if(document.URL.indexOf("/catalog/furshetnye_zakuski/")!=-1)
{
    alert("popup!");
}
</script>

A
Anton, 2020-10-02
@anton99zel

Everything is easier:
<?if (CSite::InDir('/catalog/')){?>Твой код<?}?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question