最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
想学php5的来看看!!
时间:2022-07-02 10:24:05 编辑:袖梨 来源:一聚教程网
PHP代码:--------------------------------------------------------------------------------
function FactoryMethod($class_type)
{
switch ($class_type)
{
case “foo”:
$obj = new MyFoo();
break;
case “bar”:
$obj = new MyBar();
break;
}
return $obj;
}
$object = FactoryMethod(“foo”);
$object->method()->method()
$copy_of_object = $object->__clone();
class MyClass
{
function __destruct()
{
… // Run destructor code
}
}
delete $object;
class Shape {
function __construct()
{
// shape initialization code
…
}
…
};
class Square extends Shape
{
function __construct()
{
parent::__construct();
// square-specific initialization code
…
}
…
};
class foo
{
private $priv_var;
function some_method(…)
{
$this->priv_var = …; // zend 上写的是:$priv_var = …; ,我没试过。
}
};
class Logger
{
static $m_Instance = NULL;
function Instance()
{
if(Logger::$m_Instance == NULL)
{
Logger::$m_Instance = new Logger();
}
return Logger::$m_Instance;
}
function Log()
{
…
}
};
$Logger = Logger::Instance();
$Logger->Log(…);
try
{
…code
if (failure)
{
throw new MyException(“Failure”);
}
…code
}
catch ($exception)
{
… handle exception
throw $exception; // Re-throw exception.
}
function FactoryMethod($class_type)
{
switch ($class_type)
{
case “foo”:
$obj = new MyFoo();
break;
case “bar”:
$obj = new MyBar();
break;
}
return $obj;
}
$object = FactoryMethod(“foo”);
$object->method()->method()
$copy_of_object = $object->__clone();
class MyClass
{
function __destruct()
{
… // Run destructor code
}
}
delete $object;
class Shape {
function __construct()
{
// shape initialization code
…
}
…
};
class Square extends Shape
{
function __construct()
{
parent::__construct();
// square-specific initialization code
…
}
…
};
class foo
{
private $priv_var;
function some_method(…)
{
$this->priv_var = …; // zend 上写的是:$priv_var = …; ,我没试过。
}
};
class Logger
{
static $m_Instance = NULL;
function Instance()
{
if(Logger::$m_Instance == NULL)
{
Logger::$m_Instance = new Logger();
}
return Logger::$m_Instance;
}
function Log()
{
…
}
};
$Logger = Logger::Instance();
$Logger->Log(…);
try
{
…code
if (failure)
{
throw new MyException(“Failure”);
}
…code
}
catch ($exception)
{
… handle exception
throw $exception; // Re-throw exception.
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22