Modification of non-referenced parameters possible
| From: | Till Gerken | Date: | Sun, 12 Mar 2000 18:53:17 +0000 |
| Subject: | Modification of non-referenced parameters possible | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11961@lists.php.net to get a copy of this message | ||
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, ¶meter);
(*parameter)->value.lval = 2;
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