Afficher un message
Vieux 17/09/2007, 18h01   #4
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Accessing Class Method

"RageARC" <ragearc@gmail.com> wrote in message
news:1190039567.080009.174300@o80g2000hse.googlegr oups.com...
> What if I statically call the other class function?


what if? there was nothing *static* in your example revision. main_class
could be instanciated numerous times, each with its own isolated versions of
DAL and HTML...neither of which are descriptive of what they are/do, btw.

> index.php:
> include ('dal.php');
> include ('html.php');


well, first you'd need to *require* rather than include, and that only
*once*...and each class definition would need to do this rather than just
index.php. finally, what kind of name is main_class? that describes nothing
in a system that does many things. anyway, your class would look something
like:

<?
require_once 'dal.php';
require_once 'html.php';
class main_class
{
public static $db = null;
public static $html = '';
private function __contstruct()
{
self::$db = new DAL();
self::$html = new HTML();
}
public static function initialize(){};
}
?>

> Does this code work???


work? dunno, did you test it? ;^)

this should:

index.php

<?
require_once 'main.vaguely.named.class.php';
main_class::initialze();
print_r(main_class::$db);
print_r(main_class::$html);
?>


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