-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
  • 231
  • 2
  • 3
  • 20

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") 
Tiw
  • 5,078
  • 13
  • 24
  • 33
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
  • 857,932
  • 118
  • 1,152
  • 1,264