FreeKB - if elseif else statements
PHP - if elseif else statements

An if elsif statement in PHP has the following structure.

if (comparison) {
  --do something--
  }
elseif (comparison) {
  --do something--
  }
else {
  --do something
}

 

For example.

if ($foo == 10) {
    echo "foo equals 10.";
} 
elseif ($foo == 20) {
    echo "foo equals 20.";
} 
else {
    echo "foo does not equal 10 or 20.";
}

 

Following are common if statements.

Equals

tbd

Does not equal

tbd

Greater than

tbd

Less than

tbd

Greater than or equal to

tbd

Less than or equal to

tbd

If file or directory exists

tbd

If file or directory does not exist

tbd

If variable is defined tbd
If variable is not defined tbd
If variable is empty (null) tbd
If variable is not empty (not null) tbd
If array is empty (null) tbd
If array is not empty (not null) tbd
If variable contains if (strpos($foo, "bar') == true)
If variable does not contain if (strpos($foo, "bar') == false)
If array contains if (in_array("bar", $foo ))
If array does not contain if (!in_array("bar", $foo ))
If array contains exact match tbd
If array does not contain exact match tbd
If hash contains tbd
If hash does not contain tbd
If file contains / does not contain tbd
If string begins with tbd
If string does not begin with tbd
If string ends with tbd
If string does not end with tbd

 

 


Multiple conditions

tbd



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter c2790 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |