php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30407 Strange behaviour of default arguments
Submitted: 2004-10-12 10:43 UTC Modified: 2005-02-10 12:45 UTC
From: guth at fiifo dot u-psud dot fr Assigned: dmitry
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-10-12 (dev) OS: Linux
Private report: No CVE-ID:
 [2004-10-12 10:43 UTC] guth at fiifo dot u-psud dot fr
Description:
------------
After your asked me to try an other bug with PHP 5.1.0, i tryed to run my unit tests on it.
All passes, except the following. I don't know if it's a new PHP 5.1.0 feature, but i don't think that this behaviour is really useful and it can be very confusing too.

PHP version : php5-200410111030

Reproduce code:
---------------
<?php

function haricow($a = 'one') {
	var_dump($a);
	$a = 'two';
}

haricow();
haricow();

Expected result:
----------------
string(3) "one"
string(3) "one"

Actual result:
--------------
string(3) "one"
string(3) "two"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-09 02:04 UTC] tony2001@php.net
Still reproducible with 5.1-dev.

Dmitry, could you have a look at it?
IMO it should be similar to recently fixed __set/__get bug.
 [2005-02-10 12:45 UTC] dmitry@php.net
Fixed in CVS HEAD.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 04:01:55 2014 UTC