Thursday, 19 September 2013

Using OR in IF statement

Using OR in IF statement

I am trying to write a simple IF/Else statement. I don't want to write a
bunch of lines of If, else if, else if. I thought it would be easier to
do: "If variable = x OR y OR z, then do something, else, do something.
Below is my code. I thought I was supposed to use the "||" operator, but
the code fails to execute when I'm using it this way.
Below is my example. I created a variable named "content" that is getting
a value from a recordset. If content equals "" OR " " or is NULL, then I
want to type "Content Empty", otherwise type "Content goes here".
<?php $content = $row_rsContent['content'];
if ($content == "") || ($content == " ") || (empty($content)) {
echo "Content empty"; }
else { echo "Content goes here."; } ?>

No comments:

Post a Comment