Page 1 of 1

Reading & Comprehension: Statements in PHP

Posted: Mon Jun 23, 2003 4:05 pm
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.

Posted: Mon Jun 23, 2003 5:03 pm
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.

reading

Posted: Mon Jun 23, 2003 5:04 pm
by phpScott
I like
From 0 to x times do something
phpScott

Posted: Mon Jun 23, 2003 9:43 pm
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.