php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5275 behaviour inconsistency of the `&' operator
Submitted: 2000-06-29 18:55 UTC Modified: 2000-08-01 23:25 UTC
From: teo at digiro dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (29/06/2000) OS: RH6.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: teo at digiro dot net
New email:
PHP Version: OS:

 

 [2000-06-29 18:55 UTC] teo at digiro dot net
example:
<?
class Session {
        function Session()
        {
                session_start();
                global $HTTP_SESSION_VARS, $GLOB;

                ($HTTP_SESSION_VARS != null) && ($this->_v1 = &$HTTP_SESSION_VARS);
                $this->_v2 = &$HTTP_SESSION_VARS;

                ($GLOB != null) && ($this->_v3 = &$GLOB);
                $this->_v4 = &$GLOB;
        }
}
$GLOB = 'asta e';
$s1 = new Session();

printf ("1) cmp v1 v2   = %d <br>\n", $s1->_v1 === $s1->_v2);
printf ("2) cmp v2 SESS = %d<br>\n", $s1->_v2 === $HTTP_SESSION_VARS);

printf ("3) cmp v3 v4   = %d <br>\n", $s1->_v3 === $s1->_v4);
printf ("4) cmp v4 GLOB = %d\n", $s1->_v4 === $GLOB);

The expected output would have been:
1 1 1 1
the actual result is:
0 1 1 1

Configuration: PHP4 as Apache module, register_globals off , track_vars on
The same bevaviour is shown when I try any HTTP_*_VARS that are set upon request

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-29 20:56 UTC] joey at cvs dot php dot net
Are you sure that $HTTP_SESSION_VARS is != null?
I tried your example on my machine, and HTTP_SESSION_VARS
was a null array.

I'm not sure what happens if you try to pass a reference to
a NULL variable...
 [2000-08-01 23:25 UTC] waldschrott@php.net
the expected result would have been 0 1 1 1, just because $HTTP_SESSION_VARS equal NULL: echo array()==NULL, will print out 1, thus 

echo (int)(array()!=NULL);

prints out 0
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 10:00:01 2026 UTC