php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26307 Variable reference assignments in functions
Submitted: 2003-11-18 15:58 UTC Modified: 2003-11-18 16:47 UTC
From: soywiz at hotmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.3.4 OS: Windows
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: soywiz at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-11-18 15:58 UTC] soywiz at hotmail dot com
Description:
------------
Within a function a reference to another variable cannot be assigned to its to a global variable.

I also proved this example in php 4.3.3

Sorry by my bad english

In spanish: Dentro de una funci?n no se le puede asignar a una variable global una referencia a otra variable (tambi?n global).

He probado este ejemplo en php 4.3.3 y php 4.3.4

Reproduce code:
---------------
<?php
	$a = 'a';
	$b = 'b';

	function f() {
		global $a, $b;
		$b = &$a; // Fails
	}

	f();
	echo $b;

	$b = &$a; // Works
	echo $b;
?>

Expected result:
----------------
aa

Actual result:
--------------
ba

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC