PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

想学php5的来看看

原创
2016-06-13 10:24:40 705浏览

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

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。