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 (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-10-12 (dev) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: guth at fiifo dot u-psud dot fr
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC