# __clone arguments

- Thread: https://externals.io/message/6135
- Original archive: https://news-web.php.net/php.internals/6135
- Started by Eduardo R. Maciel on 2003-12-03T18:14:06+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6135 — Eduardo R. Maciel — 2003-12-03T18:14:06+00:00

URL: https://externals.io/message/6135#6135

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/

---

## #6138 — Andi Gutmans — 2003-12-03T20:39:06+00:00

URL: https://externals.io/message/6135#6138 · In reply to: #6135

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/
