RE: PARSE ERROR, unexpected T_$VARIABLE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



On 06 December 2004 17:23, Greg Donald wrote:

> On Mon, 06 Dec 2004 11:54:50 -0500, Robert Sossomon
> <robert_sossomon@xxxxxxxx> wrote:
> > Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
> > c:\fourh\leadership\registration_post.php on line 29
> > 
> > for ($i=0; $i < count($choices); $i++)
> 
> This is bad.  Every time the for() loop iterates, the count() function
> gets called again unnecessarily.  Better to do:
> 
> $count = count( $choices );
> for ($i=0; $i < $count; $i++)

You can even do (keeping all the loop-related stuff within the for( )
construct):

   for ($i=0, $count=count($choices); $i < $count; $i++)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux