Reply to Re: Getting and Setting and best practise

Your name:

Reply:


Posted by Steve on 04/20/07 20:59

| class C_Obj
| {
| private $Obj=array('h'=>10,'i'=>12);
|
| private function getVal($name)
| {
| return $this->Obj[$name];
| }
| function &__set($name, $val)
| {
| $name = $val;
| }
| function __get($name)
| {
| return self::getVal($name);
| }
| }

yes, but here i must agree with the others. the reason why this works is
because you don't have the object's interface exposed. therefore, php
executes __set/__get. so in this case, the other posters are correct.

what the op is wanting to do with __set/__get is actually define a public
var and handle its getting/setting with private methods. the op proposed
that __set/__get would be the middle-man. it won't in any current release of
php. i'm hoping in future versions that it will, as this would make it very
similar to other oop enabled scripting languages...those that are more
robust at present.

[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

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