Bug #63714 [Opn]: incorrect global statement

From: Date: Fri, 07 Dec 2012 02:44:58 +0000
Subject: Bug #63714 [Opn]: incorrect global statement
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175180@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63714&edit=1

 ID:                 63714
 User updated by:    axdr at bk dot ru
 Reported by:        axdr at bk dot ru
 Summary:            incorrect global statement
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows
 PHP Version:        5.4.9
 Block user comment: N
 Private report:     N

 New Comment:

'global'-declaration kills referencies

  function func() {
    global $a, $b;
    $a = 'aaa';
    $b = &$a;
    echo "$a, $b", '<br>';
    global $a, $b;
    echo "$a, $b";
  }
  func();

output: 
  aaa, aaa
  aaa,


Previous Comments:
------------------------------------------------------------------------
[2012-12-07 02:37:38] axdr at bk dot ru

Description:
------------
'global'-declaration inside a function dosn't affect referencies.

Test script:
---------------
function func() {
    global $a, $b;
    $a = 'aaa';
    $b = &$a;
    $GLOBALS['c'] = &$a;
}
func();
echo "$a, $b, $c"; 



Expected result:
----------------
aaa, aaa, aaa

Actual result:
--------------
aaa, , aaa



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63714&edit=1


Thread (8 messages)

« previous php.bugs (#175180) next »