Re: default and another constructor
| From: | Mark Constable | Date: | Wed, 12 May 2004 13:58:44 +0000 |
| Subject: | Re: default and another constructor | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185993@lists.php.net to get a copy of this message | ||
On Wed, 12 May 2004 11:27 pm, Rudy Metzger wrote:
> On Wed, 2004-05-12 at 15:18, Mark Constable wrote:
> > You can at least make the below work by removing the first
> > forum() instance and using
> >
> > function forum($naam=NULL,$tijd=NULL,$tekst=NULL)
> >
> > and test the incoming variables with isset() before attempting
> > to use any of them.
>
> If you assign default values to the method arguments, you cannot test
> them with isset() anymore, as they will be set.
# cat null_test.php
<?php
class forum {
function forum($naam=NULL,$tijd=NULL,$tekst=NULL) {
var_export($naam);
echo "\n";
var_export($tijd);
echo "\n";
var_export($tekst);
echo "\n";
}
}
$test=new forum('hi');
?>
# php null_test.php
'hi'
NULL
NULL
--markc