PHP Operators

03.25.2013  |  No Comments

PHP Operators The assignment operator = is used to assign values to variables in PHP. The arithmetic operator + is used to add values together in PHP. PHP Arithmetic Operators Operator Name Description Example Result x + y Addition Sum of x and y 2 + 2 4 x – y Subtraction Difference of x and […]

Is a number even or odd? With PHP

03.24.2013  |  No Comments

$num = 18; if($num&1) { echo ‘The number is odd’; } else { echo ‘The number is even’; } And a function: function is_odd($n){ return (boolean) ($n % 2); }