Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14165

Re: strange result while passing a variable as referenz

From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.php
Subject Re: strange result while passing a variable as referenz
Date 2014-08-08 22:21 +0200
Organization solani.org
Message-ID <ls3bfk$rru$1@solani.org> (permalink)
References <pan.2014.08.08.13.54.24.561610@lars-uhlmann.de>

Show all headers | View raw


Lars Uhlmann wrote:

> PHP 5.3.3-7+squeeze21 with Suhosin-Patch (cli)

Really cli?  I'm asking because of the usage of $_SESSION.

> I like to modify $_SESSION within a function, therefore I pass it as
> reference. All my "tag"s are added to $_SESSION['data'] as expected but
> they are empty and not 'mooh'.

The script works fine under PHP 5.4.19 (*cli*) on Win7.  There *might*
be a bug in your PHP version.

> Sure I can use $_SESSION in my function directly but that's IMHO no good
> style

ACK.  However, why don't you simply return the new array and assign it
to or merge it with $_SESSION['data']?  IMHO that's even better style.

-- 
Christoph M. Becker

Back to comp.lang.php | Previous | Next | Find similar | Unroll thread


Thread

Re: strange result while passing a variable as referenz "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-08-08 22:21 +0200

csiph-web