|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78257 default arguments by reference don't work
Submitted: 2019-07-05 22:24 UTC Modified: 2019-07-05 22:43 UTC
From: amillanir1991 at gmail dot com Assigned:
Status: Not a bug Package: *Compile Issues
PHP Version: 7.3Git-2019-07-05 (snap) OS: Windows 7 64 bits
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: amillanir1991 at gmail dot com
New email:
PHP Version: OS:


 [2019-07-05 22:24 UTC] amillanir1991 at gmail dot com
function that recieve default arguments by reference don´t work, php version 7.3.6 exactly. 

Test script:
//Don´t work
$arr = [10];
function asign(&..$arr){
    $arr[0] = 100;
echo "<br> $arr[0]";
$arr = [10];
function asign(&$arr){
    $arr[0] = 100;
echo "<br> $arr[0]";

Expected result:
that the value changed into function

Actual result:
it shows nothing on the screen, not even a warning ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-05 22:35 UTC] amillanir1991 at gmail dot com
the value that show is the type NULL
 [2019-07-05 22:43 UTC]
-Status: Open +Status: Not a bug
 [2019-07-05 22:43 UTC]
$arr[0] = 100 overwrites the first argument entirely. If you want to modify the array passed as first argument, you need $arr[0][0] = 100.

Doing a var_dump($arr) after asign($arr) should make this more obvious.
 [2019-07-06 01:35 UTC] amillanir1991 at gmail dot com
thank you very much !!!!
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Apr 10 20:01:24 2021 UTC