-3

I'm trying to detect if the user has a google domain. But it is always returning true.

if($emdomain ==  "google.com" || "gmail.com") {
     array_push("google domain");
} else {
     array_push("not google domain");
}
Oliver
  • 341
  • 2
  • 4
  • 21

2 Answers2

2

Basic grammar error, your

if($emdomain ==  "google.com" || "gmail.com") 

actually equals to:

if(($emdomain ==  "google.com") || "gmail.com") 

And ( Anything || "gmail.com" ) will give True, since a string is True as boolen.
That's why it gives you first value every time.

The thing you wanted to do is:

if($emdomain ==  "google.com" || $emdomain ==  "gmail.com") 
Til
  • 5,150
  • 13
  • 26
  • 34
1

If $emdomain == "google.com" is a true value, then the if will be true.

Otherwise, if gmail.com" is a true value, then the if will be true. The string "gmail.com" will always be a true value.

Presumably the test you are trying to run is:

if ($emdomain == "google.com" || $emdomain == "gmail.com")
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335