lilnomad
10-08-2006, 12:49 PM
In the example below could someone be so kind to tell me if the objects are the variables $a, $b, $c or am I off the mark?
class classname
{
function classname($param)
{
echo "constructor called with parameter $param";
}
}
$a = new classname(“first”);
$b = new classname(“second”);
$c = new classname( );
bigfan
10-08-2006, 03:40 PM
Yes, they are.
Here's some functioning code:
class Classname
{
function Classname($param = "")
{
echo "constructor called with parameter $param<br />";
}
}
$a = new Classname('"first"');
$b = new Classname('"second"');
$c = new Classname();
Burhan
10-08-2006, 04:38 PM
is_object() (http://www.php.net/is-object) comes in handy in times like these. :)
horizon
10-08-2006, 09:57 PM
class Classname
{
function Classname($param = "")
{
if (!empty($param)) {
echo "constructor called with parameter ".$param."<br />";
}
}
}
$a = (is_object('Classname')) ? new Classname('"first"') : "";
$b = (is_object('Classname')) ? new Classname('"second"') : "";
$c = (is_object('Classname')) ? new Classname() : "";