A Little PHP
A while back when I was doing some work at my mother's house, my sister walked up behind me and looked at what I was doing. I wasn't programming anything too difficult, just a form submission page or something. She said, "I can't believe you do that for a living, I would never be able to do that!" Actually, that comment has been said to me more than several times, but the truth is, it appears a lot harder than it actually is. Look at this statement:

This snippet of code looks confusing but can easily be explained. This is called an "if statement" or a "conditional statement." It basically tells the computer what it should do in certain situations. Now, if you look at the statement closer, you will see the word balance, with a "$" preceding it. This is called a variable. This "variable" contains the value of a money account. Also on lines 2, 4, and 6, there is the word "echo" followed by some text. "Echo" is a command. This command is used to print the succeeding text to the screen. Now, on line 1 the statement is saying if the account balance is equal to 0, then the program is going to print, "There isn't any money in this account!" If that statement is not true, it goes onto the next. On line 3, if the account balance is less than 0, the program will print out, "This account is overdrawn!" Now, on line 5, it just says else. This is basically a default statement saying that if any other of the conditions fail, go with this statement. The program will print out "There is money in this account!"
If you understand the syntax in this statement, you are on your way to learning a new language. Most of the statements involved in programming are just as simple as this statement. What makes programming challenging is not the syntax, it's the logic. If it wasn't for the logic, I probably wouldn't be interested in programming at all, but as it stands, I have spent many late nights with the challenges that come along with programming. So, if you ever walk-up behind a programmer and see his code, remember that what you see is the easy part. It is the part you can't see that is difficult.
- Tracy's blog
- Login or register to post comments
