Sunday, May 31, 2009

PHP Conditional Script

This is a sample of a conditional PHP script where in the script identifies a number if it is zero, positive, negative or not a number at all.

Any number entered in the html form below will be identified.


Enter a Number



The PHP script uses the conditional statements IF, ELSE & ELSEIF to display if the number entered is zero or positive or negative or not a number at all.

<?php

IF ($_POST[number]=="0") echo "The number you entered is <b>Zero</b>";
elseif ($_POST[number] > 0)
echo "The number you entered is a <b>Positive</b> integer!";
elseif ($_POST[number] < 0)
echo "The number you entered is a <b>Negative</b> integer!";
ELSE echo "You did not enter a valid number!";

?>

0 comments:

  © Blogger template 'Minimalist G' by Ourblogtemplates.com 2008

Back to TOP