| re: Classes Can't Contain Object Members?
Yeah it is possible @ least i use it this wayi can't see the problem
maybe this will work:
class A {
var _desc;
var _obj;
function A() {
$this->_desc = "Desc test";
$this->_obj->method(); // Works here
}
function new obj()
{
$this->_obj = new B();
}
function helper() {
$this->_obj->method();
}
}
i dunno maybe try a older version of php i my self use 4.3.2 and so
think simular works there
On Sat, 11 Oct 2003 20:42:16 GMT, "Derek Battams"
<derek@stopspam.battams.ca> wrote:
[color=blue]
>Using PHP 4.3.3; I'm trying to write a class that has as a member an
>instance of another class. Assume class B is already written and supports
>the method "method()".
>
>class A {
> var _desc;
> var _obj;
>
> function A() {
> $this->_desc = "Desc test";
> $this->_obj = new B();
> $this->_obj->method(); // Works here
> }
>
> function helper() {
> $this->_obj->method(); // Parse error claiming that I'm calling a
>member function on a non-object
> return;
> }
>}
>
>Is this not possible in PHP? Is there another way?
>
>Help appreciated,
>
>Derek[/color] |