# Feature request: clone() function

- Thread: https://externals.io/message/5492
- Original archive: https://news-web.php.net/php.internals/5492
- Started by Christian Schneider on 2003-11-16T11:43:41+00:00
- Messages: 1
- 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

---

## #5492 — Christian Schneider — 2003-11-16T11:43:41+00:00

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

I'd like to see a `clone()` (or whatever name you want) function which 
should exist in both PHP4 and PHP5 and allows to clone objects in a 
compatible way.

Currently I'm using

function &clone(&$object)
{
         return (is_object($object) && version_compare(zend_version(), 
'2.0.0-dev', '<')) ? $object : $object->__clone();
}

but I think this should be provided by PHP itself to easy migration.

As always I'd be willing to provide an implementation if wanted ;-)

- Chris
