|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73742 ReflectionParameter.getDefaultValue returning wrong value when leading zeros.
Submitted: 2016-12-15 01:31 UTC Modified: 2016-12-15 01:57 UTC
From: vinipickrodt at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: Irrelevant OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: vinipickrodt at gmail dot com
New email:
PHP Version: OS:


 [2016-12-15 01:31 UTC] vinipickrodt at gmail dot com
ReflectionParameter.getDefaultValue returning wrong value when default parameter have leading zeros.

Test script:
class Foo
	public function Bar($n1 = 09, $n2 = 9){
		return 0;

$r = new ReflectionObject(new Foo());
$m = $r->getMethod("Bar");
$p1 = $m->getParameters()[0];
$p2 = $m->getParameters()[1];
echo "p1=".$p1->getDefaultValue(); //not ok. expected = 9, returning 0.
echo "<br>";
echo "p2=".$p2->getDefaultValue(); //ok = 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-15 01:57 UTC]
-Status: Open +Status: Not a bug
 [2016-12-15 01:57 UTC]
A leading zero means octal notation - base 8. 09 is invalid octal so PHP substitutes 0.

ReflectionParameter is simply how you're learning about it. You could have done
  echo 09; // 0
and discovered it that way.

If you were using PHP 7 then it would have shown you a parse error instead:
  Parse error: Invalid numeric literal in <file> on line 4
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 19:01:27 2023 UTC