PHP code: using 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 () $ 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 = ...; // Written on zend: $ priv_var = ...; I have never tried. }; 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 .}