note 100138 added to language.oop5.late-static-bindings

From: Date: Mon, 27 Sep 2010 21:38:48 +0000
Subject: note 100138 added to language.oop5.late-static-bindings
Groups: php.notes 
Request: Send a blank email to php-notes+get-172749@lists.php.net to get a copy of this message
This function can be used as a workaround for late static binding in PHP >= 5.1.0. There was another similar version of this function elsewhere, but used eval. <?php function & static_var($class, $name) { if (is_object($class)) { $class = get_class($class); } elseif ( ! is_string($class)) { throw new Exception('Must be given an object or a class name', NULL); } $class = new ReflectionClass($class); return $class->getStaticPropertyValue($name); } ?> ---- Server IP: 212.150.176.151 Probable Submitter: 77.125.96.215 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.late-static-bindings.php Edit -- https://master.php.net/note/edit/100138 Del: integrated -- https://master.php.net/note/delete/100138/integrated Del: useless -- https://master.php.net/note/delete/100138/useless Del: bad code -- https://master.php.net/note/delete/100138/bad+code Del: spam -- https://master.php.net/note/delete/100138/spam Del: non-english -- https://master.php.net/note/delete/100138/non-english Del: in docs -- https://master.php.net/note/delete/100138/in+docs Del: other reasons-- https://master.php.net/note/delete/100138 Reject -- https://master.php.net/note/reject/100138 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172749) next »