Reply to Re: Grabbing Arbitrary Amount of Function Arguments by Reference

Your name:

Reply:


Posted by Curtis on 04/01/07 20:52

Janwillem Borleffs wrote:
> Curtis wrote:
>> I have been trying to toy around with the func_get_args function,
>> however, it seems the data is copied before I can access it, as I
>> tried to globalize the values in the argument array and use
>> references, but neither worked.
>>
>
> As a workaround, you can pass the function a single array or object by
> reference:
>
> function modify(&$object) {
> $object->a = strtoupper($object->a);
> }
>
> $object = new stdClass;
> $object->a = 'a';
> modify($object);
> print $object->a; // A
>
> Note that when passing an object, it's passed by reference by default in PHP
> 5.
>
>
> JW
>
>

Ahh, thank you, I like your approach. Not sure why my mind was set on
varargs.

Thanks for the help,
Curtis, http://dyersweb.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация