单例模式PHP
单例模式例程:
<?php
class test{
private static $_instance;
private function __construct($st)
{
$test_func=$st;
$this->$test_func();
}
private function __clone(){}
public static function getInstance($st)
{ if(!self::$_instance instanceof self)
{
self::$_instance=new self($st);
}
return self::$_instance;
}
function name()
{
echo 'name namenamenamename11111111 ';
}
function pass()
{
echo 'passpasspasspasspasspass22222222222 ';
}
}
echo '12222222111<br/>';
$st=$_GET['st'];
test::getInstance($st);