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
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 22:01:31 2024 UTC