欢迎光临
我们一直在努力

想学php5的来看看!!-PHP教程,PHP基础

建站超值云服务器,限时71元/月

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.

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 想学php5的来看看!!-PHP教程,PHP基础
分享到: 更多 (0)

相关推荐

  • 暂无文章