note 101151 added to reflectionparameter.getdefaultvalue

From: Date: Tue, 30 Nov 2010 00:02:15 +0000
Subject: note 101151 added to reflectionparameter.getdefaultvalue
Groups: php.notes 
Request: Send a blank email to php-notes+get-174458@lists.php.net to get a copy of this message
It's not currently possible to obtain the name of a constant defined as a default value for a parameter. For example: <?php function foo($test, $bar = PHP_OS) { echo $test . $bar; } $function = new ReflectionFunction('foo'); foreach ($function->getParameters() as $param) { echo 'Name: ' . $param->getName() . PHP_EOL; if ($param->isOptional()) { echo 'Default value: ' . $param->getDefaultValue() . PHP_EOL; } echo PHP_EOL; } ?> Will print: Name: test Name: bar Default value: LIN Rather than: Name: test Name: bar Default value: PHP_OS If any one has an idea of how to accomplish this, I'd be interested. ---- Server IP: 208.69.120.55 Probable Submitter: 74.80.216.6 ---- Manual Page -- http://www.php.net/manual/en/reflectionparameter.getdefaultvalue.php Edit -- https://master.php.net/note/edit/101151 Del: integrated -- https://master.php.net/note/delete/101151/integrated Del: useless -- https://master.php.net/note/delete/101151/useless Del: bad code -- https://master.php.net/note/delete/101151/bad+code Del: spam -- https://master.php.net/note/delete/101151/spam Del: non-english -- https://master.php.net/note/delete/101151/non-english Del: in docs -- https://master.php.net/note/delete/101151/in+docs Del: other reasons-- https://master.php.net/note/delete/101151 Reject -- https://master.php.net/note/reject/101151 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174458) next »