Home > Backend Development > PHP Tutorial > If you want to learn php5, take a look_PHP tutorial

If you want to learn php5, take a look_PHP tutorial

WBOY
Release: 2016-07-13 17:24:23
Original
894 people have browsed it

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. }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532143.htmlTechArticlePHP代码:-------------------------------------------------------------------------------- function FactoryMethod($class_type) { switch ($class_type) { case “foo”: $obj = new M...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template