PHP conditional syntax: less than

Posted December 27, 2003 by Quinn McHenry in PHP programming

To determine if a value is less than another value, use:

if ($var < 0) echo "var is negative and non-zero";

To determine if a value is less than or equal to another value, use:

if ($var <= 0) echo "var is negative";

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.