Welcome! Log In Create A New Profile

Advanced

[PHP] class and inheritance

Posted by Alain Roger 
Alain Roger
[PHP] class and inheritance
October 21, 2008 08:50PM
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->;
> 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 ?

--
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
Maciek Sokolewicz
[PHP] Re: class and inheritance
October 21, 2008 09:15PM
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Alain Roger
[PHP] Re: class and inheritance
October 22, 2008 08:00AM
basically i did this but Zend studio for eclipse does not show me the data
or methods members after one -> :-(

On Tue, Oct 21, 2008 at 9:11 PM, Maciek Sokolewicz <[email protected]>wrote:

> 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
>



--
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
Sorry, only registered users may post in this forum.

Click here to login