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 June 9th, 2004, 03:13 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is because of the statement "global $movie_name" inside the function that the function can access the variable.

 
Old June 10th, 2004, 07:16 AM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So which one is best to use, arguments or global?

Thanks for clearing it up for me anyway guys!

:)
 
Old June 10th, 2004, 08:51 AM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Usually it's a good idea to use function arguments instead of global(izing?) a variable. Using arguments helps separate the function from the rest of the script, allowing it to be much more "modular" and increase the chance of code reuse. Using global variables ties the function to that specific script, so you probably can't take that function and use it on another project without modification.

-- Jason

 
Old June 10th, 2004, 03:55 PM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Excellent.

I can move on with confidence now.

Thanks for all your help guys.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions LTello BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 September 15th, 2006 11:15 AM
Functions czambran BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 13 July 11th, 2006 06:33 PM
answered information bar Seeker55 Javascript 1 March 28th, 2006 01:42 AM
extract function - Now answered Thank You thegooner BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 June 11th, 2004 06:44 AM





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