[PHP] Re: class and inheritance

2008-10-21 Thread Maciek Sokolewicz

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



[PHP] Re: class and inheritance

2008-10-21 Thread Alain Roger
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