Reading & Comprehension: Statements in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
HungryMind
Forum Commoner
Posts: 41
Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA

Reading & Comprehension: Statements in PHP

Post by HungryMind »

I have realized that it would be most beneficial if I could easily read through a statement in order to understand it. However, sometimes the way the statement is written really confuses me. For example:

Code: Select all

for ($counter = 0; $counter < 10; $counter++)
{
}
I know what the statement does, that's not the issue, but I am now going to take a stab at breaking the statement down into a complete sentence. PLEASE correct me if I am wrong!!!

The counter starts at 0; Run through the following action for every time the counter reads less than zero. After each time, add the value of "1" to the counter.

There must be a simpler way. So finally, is there a simple solution to reading statements? Are there easy-to-follow, universal reading steps that can apply to all statements? If so, please let me know. Thanks.
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

hi,

the trick is.... wait for it.... just get used to php and it will be second nature.. I know that's not what you want to hear but all I do is read it as english.. forget php just read it as you would a book. In this case it's tricky cos you can't really read it like that, but for the foreach example earlier this rule applies.

I read it like this:

set the start number to 0, set the stop number to 10, execute code and + 1. Repeat untill the start number is the same as the stop number.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

reading

Post by phpScott »

I like
From 0 to x times do something
phpScott
User avatar
HungryMind
Forum Commoner
Posts: 41
Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA

Post by HungryMind »

Thanks to you both. You're right, I was hoping that there was a specific way to break down each statement. Maybe someone (probably me, in the future) can write a downloadable book which will help to explain each statement and how to read each statement. Thanks again.
Post Reply