Afficher un message
Vieux 18/09/2007, 14h21   #14
RageARC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Accessing Class Method

Wow Usenet Groups rule this is better than a forum

---

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.

  Réponse avec citation
 
Page generated in 0,04668 seconds with 9 queries