Re: Accessing Class Method




"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.


.



Relevant Pages

  • Re: following radio & hidden does not work..... help please.
    ... So you query the database for records and present the concatenated fname and lname for the user to choose from. ... This works the same with a radio button or a select statement. ... This is a HTML or PHP question! ...
    (alt.html)
  • Re: Indent HTML portions question
    ... > the portion of the HTML where I jump out of php mode and back in again. ... // Connect to the database. ... errorMessage("One or more required fields were left blank. ...
    (comp.lang.php)
  • Re: following radio & hidden does not work..... help please.
    ... Using a HTML radio button form as previously stated returns all the data as requested. ... The problem seems to be HOW does one get more than one database variable to be to the PHP action program. ... The objective of the form is to use either a or a radio button form so a user can select a person from the database. ...
    (alt.html)
  • Re: Why not generate static pages instead of dynamic?
    ... html pages out there now, ... But querying a database, ... is fetched through AJAX or a 'more-dynamic' page (php ... dynamic/user-interaction page or not, and on that basis will serve the html ...
    (comp.lang.php)
  • Re: Accessing Class Method
    ... public $database; ... public $html; ...
    (comp.lang.php)