note 9032 deleted from language.oop by vincent
| From: | vincent@php.net | Date: | Thu, 11 Sep 2003 19:49:45 +0000 |
| Subject: | note 9032 deleted from language.oop by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56188@lists.php.net to get a copy of this message | ||
Note Submitter: mircho@abv.bg
----
A short comment on classes [this maybe is an answer on some previous posts.
In PHP4 [I havent tested it on PHP3]
You can't have executable code within the class declaration. Here is what I mean:
define( MY_VAR_1, 4 )
define( MY_VAR_2, 15 )
class classMyWork
{
var $nClassVar = MY_VAR_1*MY_VAR_2;
var $nClassVar = MY_VAR_1*10;
//BOTH WON'T WORK
var $hOtherClass = new classOtherClass();
//THIS WON'T WORK TOO
}
Obvoiously there's no syntactic sugar as found in Java or C++
All initialization should be performed in the class constructor
And maybe the assignment of a global variable to a class member is the same problem