Re: class inside class
| From: | Hatem Ben | Date: | Mon, 13 Jan 2003 08:53:25 +0000 |
| Subject: | Re: class inside class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131400@lists.php.net to get a copy of this message | ||
Assuming you have
class WebPage {
var $property1;
function get_property1()
{
return $this->$property1;
}
}
class Sample extends WebPage{
}
To access $property1 from your WebPage class just do
$page = new Sample;
$prop1 = $page->get_property1();
Otherwise try to send a snippets of code to see exactly what's you'r doing
:)
Regards,
Hatem
----- Original Message -----
From: "Michael Hall" <ninti@ninti.com>
To: <php-general@lists.php.net>
Sent: Monday, January 13, 2003 7:19 AM
Subject: [PHP] class inside class
> --
>
> G'day:
>
> I am using a 'wrapper' class to create all the boilerplate HTML on a
website,
> plus do stuff like authentication and print menus etc according to
properties
> set dynamically within the class.
>
> The actual content of each page is generated by seperate 'content'
classes.
> These classes are 'embedded' within and instantiated within the wrapper
class,
> but are otherwise independent of it.
>
> This system allows for something approaching a PHP "object publishing"
> application, which is where I'm heading.
>
> My problem is that now I need to get at the values of some wrapper class
> properties from within a content class: in other words, I need to access
the
> dynamically assigned values of the properties of one class, from inside
another
> class (which is embedded within the first, though I'm not sure that really
> matters).
>
> I can't use the $this-> mechanism because the value is inside a different
> class.
> I can't use the first class's handle (eg $page , from $page = new
WebPage())
> because the embedded class doesn't know about it.
> I have been playing around with declaring globals, and with PHP's
class/object
> functions, but have got nowhere yet.
>
>
> Is this possible, and if so, does anyone have any pointers? Hope my
description
> of the problem makes sense.
>
> TIA
> Mick
>
> ----------------------------------------------------
> MICHAEL HALL Web Development Officer
> Batchelor Institute of Indigenous Tertiary Education
> W: mick.hall@nt.gov.au (08) 8951 8352
> H: ninti@ninti.com (08) 8953 1442
> ----------------------------------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php