Re: Variables within functions, out?
| From: | Steve Werby | Date: | Fri, 02 Feb 2001 06:03:11 +0000 |
| Subject: | Re: Variables within functions, out? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-37796@lists.php.net to get a copy of this message | ||
"David Robley" <huntsman@hermes.nisu.flinders.edu.au> wrote:
> The specific answer to your question is that the variable $birthday is
> local to the function - check out variable scope in the manual.
>
> But in fact there is another way of doing it - pass the values to check as
> parameters to the function and have it return a result, thus:
>
> function CheckBirthday($year,$month,$day) {
This is a good solution for something this simple. [to original poster:] If
you're comfortable jumping into learning OOP (object oriented programming)
you can use classes. There are plenty of good tutorials on classes (b/w
phpbuilder.com, devshed and zend you should be set). Classes have a lot of
benefits which I won't go into, but one benefit is that it easy to use
related functions seamlessly and it's easy to create variables which are
accessible by all functions within the class (a class is essentially a
collection of functions that can talk with one another).
--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/