Linux Today: Linux News On Internet Time.

Loops & Decisions in PHP - The ABC's of PHP Part 8

May 19, 2009, 23:32 (0 Talkback[s])
(Other stories by Peter Shaw)

"As you can see it's very simple. First we have a string variable that holds a name. Then we have the "if" statement which says 'if the variable called name holds a value that is equal to peter then perform the program lines in the first set of curly brackets, otherwise perform the commands in the second set of brackets'

"The first question you might ask is why do we have a double == sign, good question. This is because in PHP everything in a decision has to result in either true or false, and since we use = to give a value to a variable, then = will always be true (trust me, computers work that way ;-) ) and thus we would not be able to get a false. There are some cases where you have to use === (3 = in succession) but for most of the time == will do just fine."

Complete Story

Related Stories: