Hello, It is not a 100% zfw question, but as I am coding under zfw, so I want if my OO coding is consistent with the zfw.
Example: I have a Class - MyClass, it is a global functional object, has the function foo() I need to call in several php files for a single HTTP request. ============ class MyClass{ function MyClass () { $this->init(); } function &getInstance { static $instance; if (!isset($instance)) { $instance = new MyClass(); } return $instance; } function init() { // Some heavy init codes... } function foo() { // core function } } ============ Which one you prefer: 1. Call as global class: $data = MyCalss::foo(); // put init() in bootstrap 2. Call as singleton $myClass =& MyClass::getInstance(); $myClass->foo(); 3. Call as new object $myClass = new MyClass(); $myClass->foo(); which method you prefer? Thanks.