Sunday 26 March 2017

[dcphp-dev] Global Variables Question

Hi all,

I am reading a book (PHP and MySQL Web Development - Thomson, Welling; 5th Ed.; Addison-Wesley) and am trying to understand the following passage regarding global variables:

You can also use the global keyword at the top of a script when a variable is first used to declare that it should be in scope throughout the script. This is possibly a more common use of the global keyword.

Can someone explain a use case for using a global variable at the top of a script? I thought that if a variable is declared outside of a function, then it is accessible throughout the script (except inside functions). I think I am missing something here.

Thanks,
Whitney 

--
You received this message because you are subscribed to the Google
Group: "Washington, DC PHP Developers Group" - http://www.dcphp.net
To post, send email to washington-dcphp-group@googlegroups.com
To unsubscribe, send email to washington-dcphp-group+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/washington-dcphp-group?hl=en
---
You received this message because you are subscribed to the Google Groups "Washington, DC PHP Developers Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to washington-dcphp-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 comments:

Post a Comment