For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2005 > initalize a static class?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author initalize a static class?
Markus Wallner

2005-08-06, 4:00 am

Hello!

Is there a way to initialize a static class similar to ___construct() in php
?

Thanks,
Markus



Janwillem Borleffs

2005-08-06, 8:59 am

Markus Wallner wrote:
> Is there a way to initialize a static class similar to ___construct()
> in php ?
>


When the constructor of the class is private, you could use a wrapper which
extends it:

class Foo {
private function __construct() {}
public function printMessage($msg) {
print $msg;
}
}

class FooBar extends Foo {
public function __construct() {}
}

$foobar = new FooBar;
$foobar->printMessage('hello');


JW



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com