|
Posted by Steve on 09/17/07 16:01
"RageARC" <ragearc@gmail.com> wrote in message
news:1190039567.080009.174300@o80g2000hse.googlegroups.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);
?>
Navigation:
[Reply to this message]
|