The developers of php simply saw no need for cloning arraysole wrote:If they can make it so it triggers an error when you use clone on a array then they could have it return the array with cloned objects. I personally feel its a hole in the functionality of the language.
Cloning an array of objects
Moderator: General Moderators
And I guess now we know the reason for
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Psst... you have "static" in the wrong placeole wrote:Code: Select all
/** * Recursively iterates over an array cloning any objects encountered * * @param array $toClone * @return array */ static public function arrayRecursiveClone(array $toClone) {
EDIT |
Manual wrote:The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
PHP 4, PHP snore. I don't care about that.d11wtq wrote:Psst... you have "static" in the wrong place
EDIT |Manual wrote:The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Oh right then its quite possible neither php 4 or 5 cares given this example.