php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17052 problem with & operator and variables
Submitted: 2002-05-06 17:46 UTC Modified: 2003-02-25 01:56 UTC
From: jx at email dot cz Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
 [2002-05-06 17:46 UTC] jx at email dot cz
this is ok

<?

$a=&$b;
$a=5;
echo($b);

?>



but when I declare these variables as globals in a function it doesn't work

<?

function foo() {
  global $a, $b;
  $a=&$b;
}

foo();
$a=5;
echo($b);

?>

It is probably allright. I didn't find anything about this problem.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-06 18:04 UTC] mfischer@php.net
This is due that variables imported into functions with the global statement are in fact references. There are open reports about this issue, marking it as duplicate for now (#14645).
 [2002-05-06 18:07 UTC] mfischer@php.net
Achja, and it's a documentation problem . . .
 [2003-02-25 01:56 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

bug #14645

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 03:01:31 2024 UTC