Answer the question
In order to leave comments, you need to log in
Why is my condition being processed incorrectly?
My script should receive a link without a host, and then the condition is fulfilled, but for some reason the condition is not displayed correctly for me and the first condition always comes out.
Here is my script
public function getPage()
{
$uri = $_SERVER['REQUEST_URI'];// Приходит /online/?utm-sources=google_adwords
if ($uri === '/'){
$page = ''; // $page = null
} else {
$page = preg_replace('/', '', $_SERVER['REQUEST_URI']);
}
return $page; //$page = null
}
Answer the question
In order to leave comments, you need to log in
=== means equal in value and type
== means equal in value
Otherwise, you are comparing a string with a string, and therefore, even if the strings are not equal, the condition is still met
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question