Reply to Re: PHP5 + SPL - Creating an object as an array.

Your name:

Reply:


Posted by Jason Barnett on 01/31/05 18:57

Yotam Ofek wrote:
> I would like to create an object like this:
> <?php
> class TestClass {
> private $some_array;
> public $just;
> public $some;
> public $public;
> public $vars;
> }
> ?>
> Is it possible, through SPL, to make the class accessible as
> "$testclass['array_key']", which will return the value for the key

Yes, this is exactly what the SPL is for. Actually the exact classes
you will want to check out are called ArrayIterator and ArrayObject.
Although I don't know for certain about making $some_array private... it
*might* need to be public. No promises either way on that one, just
look out for it ;)

> 'array_key' from "$some_array"? Not only that, but I want the class to
> be accessable as "$testclass->just" aswell!
> Is that possible? Examples are welcome.
>
> Thanks in advance,
> Yotam Ofek!


--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

[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

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