RE: [PHP] null as function argumnent?
| From: | Michael Sims | Date: | Wed, 08 Dec 2004 20:23:48 +0000 |
| Subject: | RE: [PHP] null as function argumnent? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203760@lists.php.net to get a copy of this message | ||
Bas Jobsen wrote:
> Hi,
>
> I want to use a ?: statement. If not true de default function
> argument have to be used. How to do this
>
> <?
> function test($test='default')
> {
> echo $test;
> }
> test(($value==1)?'no default':null);
>>
>
> What do i have to pass instead of null to get default print?
Try this:
function test($test = null) {
if (is_null($test)) { $test = 'default'; }
echo $test;
}
test(($value == 1) ? 'no default' : null);