Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 10:02 AM
Authorized User
 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ababb
Default Please explain this code : p131 top para

function generate_ratings($review_rating)
{
     for($i=0;$i<review_rating;$i++)
     {
          $movie_rating .= "<img src='thumbsup.gif'>&nbsp;";
     }
     return $movie_rating;
}

The part that really throws me is the 'for' with its arguments. I don't get the three arguments. I need it in English.

ABabb
Dallas TX
__________________
ABabb
Dallas TX
 
Old January 28th, 2005, 05:00 PM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for is like a while().. loop, but with a predetermined number of cycles.

broken down, this example,

$i=0; (start with $i equal to zero)
$i<$review_rating (loop until $i is equal to or greater than $movie rating)
$i++ (increment $i by one each cycle)

and equivalent while() loop would look like:

$i = 0;
while ($i < $review_rating)
{
  $movie_rating .= "<img src='thumbsup.gif'>&nbsp;";
  $i++;
}
return $movie_rating;

 
Old January 28th, 2005, 06:02 PM
Authorized User
 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ababb
Default

Thanks, that makes a lot more sense now.

Everybody knows that a function returns a value. Exactly WHERE - what line - does the function return that value?

Does the line 'return $movie_rating' return the value?

Which line of the code instructs the CPU to return to the 'for' line for another iteration?

ABabb
Dallas TX





Similar Threads
Thread Thread Starter Forum Replies Last Post
Top changes to the original code jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 August 2nd, 2007 04:10 AM
Can someone explain this code to me pandu345 Java Basics 2 October 6th, 2006 12:25 PM
Page 811; Ch15; First para after code Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 July 24th, 2006 02:26 PM
could any one explain this code for me ? method Access VBA 1 August 13th, 2005 02:02 AM
Explain some code on p178 jgrasso BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 June 3rd, 2005 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.