I have defined a class foo which has a static method that returns an instance of class foo. It works, but is it considered good practice? Is it stupid? Will it blend?
<?
class foo {
public $bar;
function __construct() {
$this->bar = 'bar is now defined';
}
public static function fetch() {
$r = new foo();
return $r;
}
}
?>
you can use it thusly:
<?php
require_once 'foo.php';
$v = foo::fetch();
print_r($v);
?>
output:
foo Object ( [bar] => bar is now defined )