Re: [PHP] global vars within 2-level functions

2002-04-02 Thread Miguel Cruz

On Tue, 2 Apr 2002, Erik Price wrote:
> On Tuesday, April 2, 2002, at 01:24  PM, Jason Wong wrote:
>>> (b) Pass a variable as an argument to a function but make that argument
>>> optional so that it does not have to exist to make the function
>>> legitimate.
>>
>> function function2 ($variable_A="") {
>> }
> 
> Thanks for the pointer.  I didn't realize that passing a blank argument 
> would achieve this effect.

Here's another way to have optional arguments, just so you're at a wealth 
of solutions:

  function function2()
  { list ($variable_A) = func_get_args();

  }

miguel


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




Re: [PHP] global vars within 2-level functions

2002-04-02 Thread Erik Price


On Tuesday, April 2, 2002, at 01:24  PM, Jason Wong wrote:

>> (b) Pass a variable as an argument to a function but make that argument
>> optional so that it does not have to exist to make the function
>> legitimate.
>
> function function2 ($variable_A="") {
> }

Thanks for the pointer.  I didn't realize that passing a blank argument 
would achieve this effect.




Erik







Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] global vars within 2-level functions

2002-04-02 Thread Jason Wong

On Wednesday 03 April 2002 02:11, Erik Price wrote:

> (b) Pass a variable as an argument to a function but make that argument
> optional so that it does not have to exist to make the function
> legitimate.

function function2 ($variable_A="") {
}

It's in manual under "Functions" -- original isn't it? :)


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Kids, the seven basic food groups are GUM, PUFF PASTRY, PIZZA,
PESTICIDES, ANTIBIOTICS, NUTRA-SWEET and MILK DUDS!!
*/

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




[PHP] global vars within 2-level functions

2002-04-02 Thread Erik Price

I have some code, in which I am using the function keyword to create 
subroutines of code (in otherwords, not true functions but rather 
reuseable chunks of other code).

Yeah, it's ugly, but I need to do it this way for now.

So my question is this:  One of my subroutine/functions generates a 
variable.  I would like to make this variable available to another 
subroutine/function, which is called from the first 
subroutine/function.  If what I say is confusing, think of it like this:

function1
   - creates variable_A
   - calls function2

function2
   - needs to access variable_A

The problem is that this variable is not available to function2, even if 
I use the "global" keyword.  The only way I can pass this variable to 
function2 is if I pass it as an argument.  However, in some cases, I 
need to call function2 without this argument, but this creates some 
Warnings which I don't want to see.  I don't want to just suppress these 
warnings, how can I either

(a) Pass a variable from a function to a subfunction called from the 
first function
(b) Pass a variable as an argument to a function but make that argument 
optional so that it does not have to exist to make the function 
legitimate.


Thank you,

Erik







Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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