Re: class and inheritance

From: Date: Tue, 21 Oct 2008 19:11:19 +0000
Subject: Re: class and inheritance
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-282211@lists.php.net to get a copy of this message
Alain Roger wrote:
Hi, I'm trying to create a class that has as public members some other class object. for that i use almost the same syntax as under C# or C++. header class:
<?php class CARMainHeader {
    // title of the main table header
    private $mTitle = null;
    // holds the height of the table header
    private $mHeight = null;
    // constructor
    public function __construct()
    {
        $this->mHeight = 15;
        $this->mTitle = "Title";
    }
    // set the title of the main table
    public function SetTitle($name)
    {
        $this->mTitle = $name;
    }
    // return the title of the main table
    public function GetTitle()
    {
        return $this->mTitle;
    }
    // set the height of the header
    public function SetHeight($height)
    {
        $this->mHeight = $height;
    }
    // return the height of the header
    public function GetHeight()
    {
        return $this->mHeight;
    }
} ?>
main class code :
<?php include_once 'CARMainHeader.php'; class CARTable {
    // holds the main table header object
    public $mTableHeader = null;
    // store the amount of columns in table
    private $mColumnsCount = null;
    // constructor
    public function __construct()
    {
        $this->mTableHeader = new CARMainHeader();
    }
    // rendering of table
    public function Render()
    {
        echo "<table>";
        echo "<tr />";
        echo "<td class=''>".$this->mTableHeader->;
you're missing something here, don't you think? :)
        echo "</td>";
        echo "<td class=''>";
        echo "</td>";
        echo "</table>";
    }
} ?>
in the CARTable, i'm not able in the Render function to write $this->mTableHeader->GetTitle(); why ? you can, and it works. Once you actually call that method.
- Tul

« previous php.general (#282211) next »