Re: Accessing Class Method
- From: "Steve" <no.one@xxxxxxxxxxx>
- Date: Tue, 18 Sep 2007 08:02:38 -0500
"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> wrote in message
news:sZudnZmNhrB4W3LbnZ2dnUVZ_oninZ2d@xxxxxxxxxxxxxx
RageARC wrote:
Wow Usenet Groups rule this is better than a forum :D
---
I tried to test some code and here's the result:
INDEX.PHP
<?php
function __autoload($class_name) {
require_once $class_name . '.php';
}
class container {
public $database;
public $html;
function __construct() {
$this->database = new database;
$this->html = new html;
}
}
$cont = new container();
$cont->html->access_db();
?>
DATABASE.PHP:
<?php
class database {
function something() {
return 'something';
}
}
?>
HTML.PHP:
<?php
class html {
function access_db() {
print database::something();
}
}
?>
It works, 100% tested ;). As you see, HTML is statically using a
method from DATABASE without any static keywords or anything. Just
code. I had already used this method before, and I didn't remember it.
I only remembered now xD.
Yes, it works now. But that doesn't mean this hole won't be fixed in
future releases.
If you're calling a method statically, it needs to be defined as a static
method. Otherwise you have a bug waiting to happen.
amen.
.
- References:
- Accessing Class Method
- From: RageARC
- Re: Accessing Class Method
- From: NoDude
- Re: Accessing Class Method
- From: RageARC
- Re: Accessing Class Method
- From: Steve
- Re: Accessing Class Method
- From: RageARC
- Re: Accessing Class Method
- From: Steve
- Re: Accessing Class Method
- From: RageARC
- Re: Accessing Class Method
- From: NoDude
- Re: Accessing Class Method
- From: Steve
- Re: Accessing Class Method
- From: NoDude
- Re: Accessing Class Method
- From: Michael Fesser
- Re: Accessing Class Method
- From: NoDude
- Re: Accessing Class Method
- From: RageARC
- Re: Accessing Class Method
- From: Jerry Stuckle
- Accessing Class Method
- Prev by Date: Re: OT - Oh, so OT.
- Next by Date: Re: OT - Oh, so OT.
- Previous by thread: Re: Accessing Class Method
- Next by thread: Re: Accessing Class Method
- Index(es):
Relevant Pages
|