Re: [PHP4BETA] Modification of non-referenced parameters possible

From: Date: Sun, 12 Mar 2000 18:52:57 +0000
Subject: Re: [PHP4BETA] Modification of non-referenced parameters possible
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-11963@lists.php.net to get a copy of this message
On Sun, 12 Mar 2000, Till Gerken wrote: > Hello, > > I have been getting errors numerous times I tried to post this message, > please excuse me if it has been delivered more than once. > > I do not know whether I came across a wanted functionality or a bug. I have > not been able to verify the following behaviour with the available > documentation or the message archives. Please correct me if I am wrong. > > When I create a new module for PHP that exports the function "testfunction" > which simply accepts one parameter, this function is able to modify its > parameter, regardless if it has been passed by reference or not. > > The C code for the function: > > pval **parameter; > zend_get_parameters_ex(1, &parameter); > (*parameter)->value.lval = 2; You are not allowed to change parameters you use the _ex() functions on. They are read-only! If you want to change your parameters, then please use the non-ex functions. Andi > > The PHP code: > > $param = 1; > testfunction($param); > print($param); > $param = 1; > testfunction(&$param); > print($param); > > Both times $param will end up being modified to "2". I am pretty sure that I > am doing something wrong, but where am I mislead? > > Till > > > >

« previous php.version4 (#11963) next »