PHP - Bits & Pieces

PHP programming codes and scripting are discussed in the manner of use and relevance. Examples of PHP syntax and scripting are presented in concise writups for better understanding.

Thursday, May 22, 2008

Using PHP to find Out if a Nummber is Odd or Even

This little bit of scripts was most useful in the coding of Waist Shaping Knitting Calculator . It evens out the number of knitting stitches so that both sides of the waist line get to be adjusted evenly.

The 'if' condition tests if variable '$Sts' is an odd number:

if( $Sts & 1 ){
$Sts = $Sts + 1;} //true when $Sts is odd, so add 1 to $Sts to make it even.


This bit of php will be useful for further development of the Knitting Calculator series.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home