Reply to Re: is this possible in PHP

Your name:

Reply:


Posted by C. on 08/01/07 16:36

On 29 Jul, 18:08, Rik <luiheidsgoe...@hotmail.com> wrote:
> On Sun, 29 Jul 2007 18:53:24 +0200, Jeff
>
>
>
> <it_consulta...@hotmail.com.NOSPAM> wrote:
> > I'm wondering if something similar is possible with
> > object-oriented PHP (5.2.3) programming??
>
>
>
> An implementation of this could be:
>
> <?php
> class Period{
> private $_second;
>
> function __set($name,$value){
> echo 'Setting '.$name;
> $this->$name = $value;
> }
> function __get($name){
> echo 'Getting '.$name;
> if(isset($this->$name)) return $this->$name;
> echo 'No such property: Period::'.$name;
> }}
>
> $foo = new Period();
> $foo->_second = 123;
> echo $foo->_second ;
> ?>

Which neatly demonstrates PHPs built in methods for objects - but is
probably overkill as a solution to the problem. I don't really
know .NET but I suspect this class stores a value and when a new value
is set it returns the previous value. In which case:

class Period
{
private $_second;
function Seconds($value)
{
$prev=$this->_second;
$this->_second=(double)$value;
return($prev);
}
}

C.

[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

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