You are here: Re: how to init a member variable in a class? « All PHP « IT news, forums, messages
Re: how to init a member variable in a class?

Posted by Markus Wallner on 07/31/05 15:22

Thanks a bunch!


"Janwillem Borleffs" <jw@jwscripts.com> schrieb im Newsbeitrag
news:42ecc168$0$68121$dbd49001@news.euronet.nl...
> Markus Wallner wrote:
>> class XYZ {
>> var $stdmail = $MAIL_COMMON;
>> }
>>
>> I always get the error message "unexpected T_VARIABLE in (second
>> file)".
>> Also tried it with $SESSION and $GLOBALS, but nothing works.
>> Using PHP 4.0.5, Apache 2.0.54.
>>
>> What am I doing wrong?
>>
>
> You should assign it in the constructor:
>
> class XYZ {
> var $stdmail;
>
> function XYZ() {
> $this->stdmail = $GLOBALS['MAIL_COMMON'];
> }
> }
>
> Or just define $MAIL_COMMON as a constant, in which case you can use it
> straight away:
>
> define('MAIL_COMMON', 'xxx@ddd');
>
> class XYZ {
> ...
> function sendMail() {
> mail(MAIL_COMMON, ......);
> }
> }
>
>
> JW
>
>
>

 

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

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