Re: [Phphtmllib-devel] Strange Class behaviour...
Status: Beta
Brought to you by:
hemna
|
From: walt b. <wab...@3g...> - 2003-07-07 17:29:55
|
Mark Lawrence wrote:
>Hi,
>
>I haven't seen much activity on this list, so I hope you are all still
>around :-) The following code is giving me problems:
>
---yah its still alive, I've just been super busy lately. I need to get
2.2.5 out the door.
>
>
>class NewTheme {
>
> var $page, $content;
>
> function NewTheme () {
>
> $this->$page =& new HTMLPageClass($title, XHTML_TRANSITIONAL);
>
> print get_class($this->$page) . "<br>";
>
> $this->$content =& new DIVtag;
>
> print get_class($this->$page) . "<br>";
>
> }
>}
>
what is the value of the $content var?
$this->$content =& new DIVtag; has the potential to do bad things
as does $this->$page, because you are doing a variable variable for
$page and $content.
The normal way to access member vars in a class is
$this->page
$this->content
Try that.
Walt
>
>The output of this is:
>
>htmlpageclass
>divtag
>
>when I would have expected it to be
>
>htmlpageclass
>htmlpageclass
>
>Specifically, it appears that creating a new DIVtag object is
>overwriting the value of the $page variable.
>
>I have read a lot of comments about classes and object in php in general,
>but I can't determine if this is a generic problem or not.
>
>Any clues on how to work around this behaviour?
>
>Cheers, Mark.
>
>
|