Re: Class and subclass

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$> php -r '
class A
{
function render() { echo "foo\n"; }
}

class B
{
function __construct() {
$this->a = new A;
}

function test() { $this->a->render(); }
}

$b = new B;
$b->test();
'
foo




... works for me.


Alain Roger wrote:
> Hi,
> 
> i have a class A with some properties.
> i have a class B with several public functions (i.e : Render())
> 
> i would like to do something like that :
> 
> class B()

	 ^^--- ???

> {
> B()
> {
> }
> 
> public function Render()
> {
>  ...
> }
> }
> 
> class A
> {
> private $myotherclass;
> 
> A()
> {
>  $this->myotherclass = new classB();
> }
> 
> public function test()
> {
>  $this->myotherclass->Render();
> }
> }
> 
> however, i'm not able to access to ->Render() of class B from Class A
> property. Where could be the problem ?
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux