Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
low cost magazines
gambling sites
wwwstores
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Odd Or even


Odd Or even

This is a very popular type of function on other programming sites and here is our php version of this . All this does is simply display a message whether a value is odd or even .

Here is the script in full

<?php
/*
This function takes a whole number ($intnumber)
and then displays a message depending on whether
it is odd or even
*/
function OddOrEven($intNumber)
{
if ($intNumber % 2 == 0 )
{
//your number is even
echo "Your number is even<br>";
}
else
{
//your number is odd
echo "Your number is odd<br>";
}
}
//test the function with 2 values 40 and 3
OddOrEven(40);
OddOrEven(3);
?>

A note here for people coming from other languages , in particular Visual Basic or VBscript . The modulus operator is % and not MOD . If you program in more than one language this will catch you out from time to time.

And here is the output


Your number is even
Your number is odd




Books
 Sponsors
 Random Code
gethostbynamel function(functions)
Processor information(functions)
Basic currency conversion(application)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.