Re: Class declaration, constants and array
| From: | Bret Hughes | Date: | Sat, 29 Jan 2005 01:38:51 +0000 |
| Subject: | Re: Class declaration, constants and array | ||
| References: | 1 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-207657@lists.php.net to get a copy of this message | ||
On Fri, 2005-01-28 at 14:50, Marek wrote:
> php5 class {
>
> const _SOMETHING_ = 'test';
>
> private $abc=_SOMETHING_; // fails, well actually anything fails
> similar to this.
> var $test=$test2; // also fails
>
> So since I can not use dynamic var assignment within the class declaration,
> what are some of the easy solutions to this ? without making anything global
> to the script ?
>
> Thanks
I believe you will have to establish stuff like this in the
constructor. jsut create a function the same name as the class and it
will be run on object instantiation. I had to do the a couple of years
ago for an array.
Check out the manual it used to explain this.
Bret