Re: Object Constructors in PHP

From: Date: Fri, 06 Apr 2001 06:46:35 +0000
Subject: Re: Object Constructors in PHP
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-50997@lists.php.net to get a copy of this message
From: "Steven Roussey" <sroussey@network54.com> Sent: Friday, April 06, 2001 2:19 AM Subject: [PHP-DEV] Object Constructors in PHP > Don't ask why it is this way, but say we have these files: <snip code> Bad bad BAD programmer! Go to your corner. :-) > It runs fine printing 'hi' (though not with APC, but fine with Zend Cache). > > BUT, What _should_ happen? You mean from a PHP perspective or from an OOP perspective? Your example runs as expected. The contructur Outline_ForumStyle() calls the inherited method ForumStyle(). Nothing wrong with that. I think what would be more interesting is, what happens if you instantiate ForumStyle? $f = new ForumStyle(); From an OOP POV, there is no contructor, so nothing should happen. PHP OTOH recognises the inherited method ForumStyle() as having the same name as the class, thereby making it a contructor. Not good IMHO, but i think it stems from the fact that PHP does not have a keyword for explicitly defining contructors, like you find in Java or C++. One of the areas in PHP that still need some work is IMHO the OOP area. Some things are a bit too loosly defined - even for a script language. - Carsten

« previous php.dev (#50997) next »