RE: note 62796 rejected and deleted from language.oop5.static by notes editor betz

From: Date: Thu, 09 Mar 2006 20:35:34 +0000
Subject: RE: note 62796 rejected and deleted from language.oop5.static by notes editor betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-105166@lists.php.net to get a copy of this message
Found the answer to my question: You cant do: return $translated::instance(); You have to do: eval("$$sam = " . $translated . '::instance();'); return sam; Mike -----Original Message----- From: php-notes@lists.php.net [mailto:php-notes@lists.php.net] Sent: Thursday, March 09, 2006 3:35 PM To: mmastran@purdue.edu Subject: note 62796 rejected and deleted from language.oop5.static by notes editor betz You are receiving this email because your note posted to the online PHP manual has been removed by one of the editors. Read the following paragraphs carefully, because they contain pointers to resources better suited for requesting support or reporting bugs, none of which are to be included in manual notes because there are mechanisms and groups in place to deal with those issues. The user contributed notes are not an appropriate place to ask questions, report bugs or suggest new features; please use the resources listed on <http://php.net/support> for those purposes. This was clearly stated in the page you used to submit your note, please carefully re-read those instructions before submitting future contributions. Bug submissions and feature requests should be entered at <http://bugs.php.net/>. For documentation errors use the bug system, and classify the bug as "Documentation problem". Support and ways to find answers to your questions can be found at <http://php.net/support>. Your note has been removed from the online manual. ----- Copy of your note below ----- can anyone find the how to fix the bottom? class Logging { static private $instance = false; function __construct() { if (Logging::$instance) { throw new Exception("trying to instantiate a singleton"); } Logging::$instance = $this; } static function instance() { if(!Logging::$instance) { Logging::$instance = new Logging(); } return Logging::$instance; } } $translated = "Logging"; // can be many other things try { return new $translated(); } catch (Exception $e) { echo "$translated is a singleton<br>"; // return Logging::instance(); // works // return $translated::instance(); // doesnt work }

« previous php.notes (#105166) next »