note 108620 added to reflectionparameter.getclass

From: Date: Fri, 11 May 2012 09:15:16 +0000
Subject: note 108620 added to reflectionparameter.getclass
Groups: php.notes 
Request: Send a blank email to php-notes+get-187935@lists.php.net to get a copy of this message
ReflectionParameter::getClass() will cause a fatal error (and trigger __autoload) if the class required by the parameter is not defined. Sometimes it's useful to only know the class name without needing the class to be loaded. Here's a simple function that will retrieve only the class name without requiring the class to exist: <?php function getClassName(ReflectionParameter $param) { preg_match('/\[\s\<\w+?>\s([\w]+)/s', $param->__toString(), $matches); return isset($matches[1]) ? $matches[1] : null; } ?> ---- Server IP: 79.99.203.17 Probable Submitter: 176.35.148.153 ---- Manual Page -- http://www.php.net/manual/en/reflectionparameter.getclass.php Edit -- https://master.php.net/note/edit/108620 Del: integrated -- https://master.php.net/note/delete/108620/integrated Del: useless -- https://master.php.net/note/delete/108620/useless Del: bad code -- https://master.php.net/note/delete/108620/bad+code Del: spam -- https://master.php.net/note/delete/108620/spam Del: non-english -- https://master.php.net/note/delete/108620/non-english Del: in docs -- https://master.php.net/note/delete/108620/in+docs Del: other reasons-- https://master.php.net/note/delete/108620 Reject -- https://master.php.net/note/reject/108620 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187935) next »