RE: [PHP] Can a class instance a property of another class

From: Date: Fri, 26 Jan 2007 23:30:20 +0000
Subject: RE: [PHP] Can a class instance a property of another class
Groups: php.general 
Request: Send a blank email to php-general+get-247863@lists.php.net to get a copy of this message
[snip] I would like to have a class instance be the property of another class, like can be done in other languages. For example: I would like to have a "Connections" class which contains all of the database connection logic and query results. There are advantages to having this type of utility class be local to a data or business class. (I know that I could have a generic "include" with functions outside of the class hierarchy.) So, in the __construct method of a business or data class, for example, one could: include_once("connection_classes.kbk"); $this->connection_class = new connection_class; This syntax fails, so I know this isn't right, but I hope you get the idea. Can it be done? [/snip] Extends? class new_connection extends connection {}

« previous php.general (#247863) next »