FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Completely stumped
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Completely stumped (still) [message #185114 is a reply to message #185107] Wed, 26 February 2014 23:21 Go to previous messageGo to previous message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma:
Senior Member
Thomas 'PointedEars' Lahn wrote:

> Christoph Michael Becker wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Christoph Michael Becker wrote:
>>>> Thomas 'PointedEars' Lahn wrote:
>>>> > Christoph Michael Becker wrote:
>>>> >> Thomas 'PointedEars' Lahn wrote:
>>>> >>> $*_VARS were first.
>>>> >>
>>>> >> According to the manual $HTTP_SESSION_VARS and $_SESSION are different
>>>> >> variables, anyway.[1]
>>>> >>
>>>> >> [1] <http://www.php.net/manual/en/reserved.variables.session.php>
>>>> >
>>>> > $_SESSION is a superglobal; $HTTP_SESSION_VARS is/was not (i.e., it
>>>> > needs to be declared a global if it is to be accessed from local
>>>> > context). But I am quite certain that when both were still supported,
>>>> > if you modified one, you modified the other (I have only PHP 5.5.9 to
>>>> > test with, where there is no $HTTP_SESSION_VARS anymore).
>>>>
>>>> The manual says:
>>>>
>>>> | $HTTP_SESSION_VARS contains the same initial information, but is not
>>>> | a superglobal. (Note that $HTTP_SESSION_VARS and $_SESSION are
>>>> | different variables and that PHP handles them as such)
>>>
>>> I *know* what the manual says. That does not prove anything.
>>
>> Testing on a single system might not prove much more, either. Anyway, I
>> tested the following script on PHP 5.2.13 (FCGI, register_globals=On or
>> Off, register_long_arrays=On):
>>
>> <?php
>>
>> session_start();
>> var_dump($HTTP_SESSION_VARS["foo"]);
>> $_SESSION["foo"] = "bar";
>> var_dump($HTTP_SESSION_VARS["foo"]);
>>
>> The result really surprised me:
>>
>> string(3) "bar" string(3) "bar"
>>
>> The output is the same, if I switch $HTTP_SESSION_VARS and $_SESSION. A
>> similar test regarding $_GET and $HTTP_GET_VARS showed the documented
>> behavior, by the way.
>>
>> It seems that is a documentation bug.
>
> ACK.
>
>> However, I suppose that's mostly rrelevant now, because the bug tracker is
>> concerned with PHP 5.4-5.6, and says wrt. earlier versions: "upgrade
>> first". But since PHP 5.4 register_long_arrays has been removed, so I
>> conclude that the $HTTP_*_VARS have been removed also,
>
> They have been removed indeed, as you can see in my PHP 5.5 test results.
>
> I found it curiouser, though, that you can use “global” outside a function.
> And not only that (which makes some sense as the file can be included), but
> that apparently you can actually *declare* a global variable in PHP this way
> (in my case, the previously non-existing $HTTP_SESSION_VARS).

Indeed, the behavior is somewhat strange. However, it becomes more
understandable, considering what global actually does: it creates a
local variable as a reference to the respective global variable. So the
following functions are equivalent (if I'm not mistaken):

function foo() {
global $a;
echo $a;
}

function bar() {
$a =& $GLOBALS['a'];
echo $a;
}

>> in which case their documentation is even more in error, because it states
>> they are deprecated, but doesn't mention that they have been removed.
>> Now I am completely stumped.
>
> ACK.

Thanks for the confirmation. I have filed a doc bug report now[1].

[1] <https://bugs.php.net/bug.php?id=66784>


--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: JavaScript to PHP
Next Topic: Why is polymorphism in PHP not like other languages? Is there a bug in PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 04:36:04 GMT 2024

Total time taken to generate the page: 0.04468 seconds