I'm trying to write a class with a constructor that takes a single object
parameter. So far so good, but I can't for the life of me make the parameter
optional. I understand how to do it with a numerical or textual parameter,
but not with an object. I tried null, but it doesn't work.
class A
{
}
class B
{
function B($a = ???)
{
if (!isset($a)) $a = new A;
}
}
Any ideas?
Jaka
parameter. So far so good, but I can't for the life of me make the parameter
optional. I understand how to do it with a numerical or textual parameter,
but not with an object. I tried null, but it doesn't work.
class A
{
}
class B
{
function B($a = ???)
{
if (!isset($a)) $a = new A;
}
}
Any ideas?
Jaka
Comment