Re: [PHP] 'undef' as an argument value

2002-03-12 Thread Jordan S. Jones

function foo ($arg1_required, $arg2_options = "") {
if (empty($arg2_optional) {
print "not passed";
} else {
print "explicit";
}
}

Or you can go the other route.

Jordan

"Rodent Of Unusual Size" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Rick Emery wrote:
> >
> > function foo($arg1_required, $arg2_optional="")
> > if ($arg2_optional=="") {
> > print "not passed";
> > }
> > else {
> > print "explicit";
> > }
> > }
>
> No, I said 'undef' because I mean 'undefined'.  The argument
> can have *any* value; I need to know when it has *none*.  That
> is, there is no magic cookie to which I can set the default that
> might not be a valid call value.
> --
> #ken P-)}
>
> Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
> Author, developer, opinionist  http://Apache-Server.Com/
>
> "Millennium hand and shrimp!"



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




Re: [PHP] 'undef' as an argument value

2002-03-11 Thread Rodent of Unusual Size

"Johnson, Kirk" wrote:
> 
> http://www.php.net/manual/en/function.func-num-args.php will
> return the number of arguments passed to the function.

Bingo!  That will do the trick..  Thanks *very* much!
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

"Millennium hand and shrimp!"

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




RE: [PHP] 'undef' as an argument value

2002-03-11 Thread Johnson, Kirk

http://www.php.net/manual/en/function.func-num-args.php will return the
number of arguments passed to the function.

Kirk

> -Original Message-
> From: Rodent of Unusual Size [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 11, 2002 2:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] 'undef' as an argument value
> 
> 
> Rick Emery wrote:
> > 
> > function foo($arg1_required, $arg2_optional="")
> > if ($arg2_optional=="") {
> > print "not passed";
> > }
> > else {
> > print "explicit";
> > }
> > }
> 
> No, I said 'undef' because I mean 'undefined'.  The argument
> can have *any* value; I need to know when it has *none*.  That
> is, there is no magic cookie to which I can set the default that
> might not be a valid call value.
> -- 
> #ken  P-)}
> 
> Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
> Author, developer, opinionist  http://Apache-Server.Com/

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




Re: [PHP] 'undef' as an argument value

2002-03-11 Thread Rodent of Unusual Size

Rick Emery wrote:
> 
> function foo($arg1_required, $arg2_optional="")
> if ($arg2_optional=="") {
> print "not passed";
> }
> else {
> print "explicit";
> }
> }

No, I said 'undef' because I mean 'undefined'.  The argument
can have *any* value; I need to know when it has *none*.  That
is, there is no magic cookie to which I can set the default that
might not be a valid call value.
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

"Millennium hand and shrimp!"

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




RE: [PHP] 'undef' as an argument value

2002-03-11 Thread Rick Emery

function foo($arg1_required, $arg2_optional="")
if ($arg2_optional=="") {
print "not passed";
}
else {
print "explicit";
}
}

-Original Message-
From: Rodent of Unusual Size [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 3:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP] 'undef' as an argument value


An odd request..  I want to have optional function arguments
that *aren't* defined unless values are explicitly passed.  Sorta
the equivalent of

function foo($arg1_required, $arg2_optional=undef)
if (isset($arg2_optional)) {
print "explicit";
}
else {
print "not passed";
}
}

Something like this is possible in Perl through the 'undef'
construct; is anything like this available in PHP?
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

"Millennium hand and shrimp!"

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

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




[PHP] 'undef' as an argument value

2002-03-11 Thread Rodent of Unusual Size

An odd request..  I want to have optional function arguments
that *aren't* defined unless values are explicitly passed.  Sorta
the equivalent of

function foo($arg1_required, $arg2_optional=undef)
if (isset($arg2_optional)) {
print "explicit";
}
else {
print "not passed";
}
}

Something like this is possible in Perl through the 'undef'
construct; is anything like this available in PHP?
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

"Millennium hand and shrimp!"

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