Trying to understand || for if statement

How would I format the following code to check for multiple $userip results?

Such as IP’s:,


	 if ($userip == ""){ 
	 echo "You are blocked from using this.";
              include "footer.php";

I tried this below, but something is wrong here…other than me being new to PHP :slight_smile:

if ($userip == “” || “”){

if ($userip == "" || $userip == ""){

An easier way to check against multiple IP’s is to use an array

$check_ip = array('','');

if (in_array($userip, $check_ip)) {
    // PHP code to run here

Id use a switch…


      case '' : /*do stuff*/; break;
      case '' : /*do stuff*/; break;

The only downside to a switch is if at a point you decide to change to a database driven IP blocker you would just append them as a case within it so an array would be the best option.

I would personally go with an array too, not to say that a switch doesnt have it’s uses though.
To answer the OP’s original question thought, you have to compare each value as you can ‘string together’ when comparing variables

if ($userip == "" || $userip == ""){