PHP's

PHP's

For example, I recently had to code a project that looked at the variable "mQ1." If that variable had a value of "0" (zero), then I had to subtract 1 from the variable "mDIV"

So, my PHP code looked like this:

if ($mQ1 == 0) { $mDIV = $mDIV - 1; }

I'll break this down real quick.

if ($mQ1 == 0)
This is our "look" -- we are taking a look at the variable $mQ1. If it does equal zero, then the rest of our statement (in the brackets) will be performed. If false, then the statements in the bracket will be ignored.

{ $mDIV = $mDIV - 1; }
This is the statement that takes place is the "If" statement is TRUE. I am simply subtracting 1 from the $mDIV variable. And That's it!

Posted: 2007-03-31


Reader Comments


PennComm Family of Websites: JabberGroups Youth Group Manager | JabberText Group Text Messaging | WebOSCenter.com Palm & WebOS News