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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Sep 28 01:01:27 2024 UTC