Sorry if it has been discussed before, but how is the
question about __clone accept arguments ???
It would permit a better control when clonning
objects, like dinamically setting properties.
Sure its is possible using wrappers, but would be
better if the function supports that.
class clonable{
public $age;
public $b;
// function __clone($a){
// if ($a) $this->age = $a;
// else $this->age = $that->age;
// }
}
$molly = new clonable;
$molly->age = 1;
$dolly = $molly->__clone(0);
echo $dolly->age;
if ($dolly == $molly) echo "equal: TRUE";
else {
var_dump($dolly);
var_dump($molly);
}
if ($dolly === $molly) echo "identical: TRUE";
else {
var_dump($dolly);
var_dump($molly);
}
Eduardo R. Maciel
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
It doesn't accept arguments. An object should know how to clone itself
without additional information. If you want a method which does something
other than cloning then define your own method.
Andi
At 10:14 AM 12/3/2003 -0800, Eduardo R. Maciel wrote:
Sorry if it has been discussed before, but how is the
question about __clone accept arguments ???
It would permit a better control when clonning
objects, like dinamically setting properties.Sure its is possible using wrappers, but would be
better if the function supports that.class clonable{
public $age; public $b;
// function __clone($a){
// if ($a) $this->age = $a;
// else $this->age = $that->age;
// }}
$molly = new clonable;
$molly->age = 1;
$dolly = $molly->__clone(0);
echo $dolly->age;
if ($dolly == $molly) echo "equal: TRUE";
else {
var_dump($dolly);
var_dump($molly);
}
if ($dolly === $molly) echo "identical: TRUE";
else {
var_dump($dolly);
var_dump($molly);
}Eduardo R. Maciel
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/