You are here: Re: _construct() problem « PHP « IT news, forums, messages
Re: _construct() problem

Posted by Catalin Trifu on 06/09/05 16:37

Hi,

What aout __construct() ->thi shoul do the trick (read the manual)

Catalin


Stéphane Bruno wrote:
> Hello,
>
> I designed a "player" class with the following properties and
> constructor:
>
> class player {
> private $properties = array('firstname' => NULL, 'lastname' => NULL);
>
> function _construct($first, $last) {
> $this->properties['firstname'] = $first;
> $this->properties['lastname'] = $last;
> }
> }
>
> Then I have other methods that allow me to set and get the properties.
> However, when I issue a:
>
> $myplayer = new player('Laurent', 'Blanc');
>
> it seems that the constructor is not taken into account: the properties
> are not initialized. I have to explicitly initialize them with the
> setter methods in order for the initialization to take place.
>
> What did I do wrong?
>
> I am running PHP 5.0.4 with Apache 2.0.54 on Fedora Core 1.
>
> Stéphane

 

Navigation:

[Reply to this 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

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