Edit report at http://bugs.php.net/bug.php?id=12533&edit=1
ID: 12533
Comment by: magister99 at hotmail dot com
Reported by: pmateesc at dynasty dot com
Summary: Reference and global keyword don't work as
documented
Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: W2k, Linux
PHP Version: 4.0.6
Block user comment: N
New Comment:
Hi! What is posted in the manual does not work as expected:
class DTO
{
public $msgs = "ergegefr";
public $a = 1;
public $b = 2;
function Insert(){
global $msgsb, $a, $b;
$b = $a + $b;
print $msgs; //Prints nothing
print $b; //Prints 0
}
}
Previous Comments:
------------------------------------------------------------------------
[2001-12-14 14:37:42] [email protected]
This is explained in the Manual. Please ask support question to
php-general.
Note: Reference is not a pointer. This is confiuing, but it will not be
fixed.
------------------------------------------------------------------------
[2001-08-02 10:26:44] pmateesc at dynasty dot com
<?
$a = 1;
$b = 2;
function Sum() {
global $a, $b;
$b = &$a;
}
echo "a=$a b=$b";
?>
I expect echo to output "a=1 b=1" since within Sum I set the variable $b
(which refers to global $b) as a reference to $a.
However, this works using $GLOBALS instead of the keyword global.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=12533&edit=1