ID:               31899
 User updated by:  php at simplicate dot it
 Reported By:      php at simplicate dot it
-Status:           Bogus
+Status:           Open
 Bug Type:         Variables related
 Operating System: Linux 2.4.22-1.2199 - Apache 2.0
 PHP Version:      4.3.8
 New Comment:

What? sorry i really don't understand what you are talking about.. i am
trying to set the value of $mmm... thats why it currently has no
value... the behaviour of $$var should be $(value of $var) which is
'mmm' so the variable variable should resolve to $('mmm') not the value
of $mmm as that would be rediculous, talk about recurssion!!!

Anyway that is beside the point - i know i am correct because the whole
thing works when not in the confines of a function. All this information
can be found on the link that i posted.

        $v      = 'albert';
        $var    = 'mmm';
        $$var   = &$v;

This works fine...! so why putting it within a function does anything
change... unless you can't safely globalize a variable variable... (ie.
global $$var - but this works for other values) or variable variabling a
reference changes the behaviour of the variable variable????

i couldn't find any information about this problem / feature in the
references section or the variable variables section so where else can
i look, i even searched the whole site for anything along the same
lines??? And i reject the insinuation that i didn't check it in the
first place...

It also works if i remove the referencing to $v and just copy $v's
value:

        $v = 'albert';

        function test($var){

                global $$var, $v;

                $$var = $v; // <--- no referencing!!

        }

        test('mmm');

        var_dump($mmm);
        exit;

The above code works fine and $mmm is set to the correct value "albert"
outside of the functions reach.

So what is going on, please can you give me a better explaination? this
problem causes me no hinderance what-so-ever as i can code around it to
my hearts content but anything that i see as a flaw in logic leaves me
to worry about the reliability of a language. You may be a volenteer
and you probably have to wade through a lot of requests, but if a jobs
worth doing its worth doing well and i really think that you haven't
fully looked into what i "took the time" to write.

Thank you


Previous Comments:
------------------------------------------------------------------------

[2005-02-09 22:37:57] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$$var = &$v;

resolves to

$(value of $mmm) = &$v;

Since $mmm contains no value nothing happens.

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

[2005-02-09 16:18:40] php at simplicate dot it

In order for the link i posted to work it needs to include the "08" on
the end... altho it has been wrapped by your parser function, just
making sure - it maybe quite obvious but i really want this problem
looked into / commented on and not cast aside.

http://ourproperty.co.uk/test/index.php?code=0&allowin=SECurePHRase808

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

[2005-02-09 16:08:54] php at simplicate dot it

Description:
------------
When a variable variable is globalized into a function and then its
value is set to a reference of another variable, the variable
variable's value does not extend past that of the function.

Reproduce code:
---------------
$v = 'albert';

function test($var){

        global $$var, $v;

        $$var = &$v;

}

test('mmm');

var_dump($mmm);
exit;

// for further examples follow the link below:
//
http://www.ourproperty.co.uk/test/index.php?code=0&allowin=SECurePHRase808


Expected result:
----------------
string(6) "albert" 

Actual result:
--------------
NULL


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


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

Reply via email to