I'm not sure if your getting a bit confused between classes and objects. A class is the blueprint for an object, that is, a class defines the properties and methods and an object is an instance of that class.
Tn answer your question yes an object can contain other objects, for example
class MySQL
{
function mySQL()
{
// Connect to database
}
function doQuery($query)
{
// Do a query
}
}
class Page
{
var $mysql;
function page(&$mysql)
{
$this->mysql =& $mysql;
}
function displayPage()
{
$queryresult = $this->mysql->doQuery("A mysql query");
// Do something with query result
}
}
$mysql = new MySQL;
$page = new Page($mysql);
$page->displayPage();
In this case the Page class accepts a paremeter in it's constructor which is an instance of the MySQL querying class. Note that each class has a function which has the same name as the class. This is it's constructor, and it's executed when the class is created.