Re: [PHP4BETA] CVS update: php4/ext/standard
| From: | Andi Gutmans | Date: | Sun, 06 Jun 1999 16:59:31 +0000 |
| Subject: | Re: [PHP4BETA] CVS update: php4/ext/standard | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-1323@lists.php.net to get a copy of this message | ||
At 22:40 05/06/99 -0500, Andrey Zmievski wrote:
At 06:18 AM 6/6/99 +0200, you wrote: I don't have time to look at this code thoroughly right now but it seems there's a problem here. Unless you have a reason for doing this and I'm just not realizing it because I don't have time to look at the code now, you are changing variables to is_ref and increasing the reference count without doing extra work. However if your reference count is more than 1 and the variable is not is_ref before you do this, you'll have to break away this variable from whatever other variables that are pointing at it. Let me know if this is the case, and I'll talk to Zeev about writing some API function. We wouldn't want you to implement this in each place yourself, it'd be better to have something general that will do the break away code as it exists already. Ok, what I was trying to do put the actual passed value in the array, not a copy of it. So that: $ar = array("test"); $b = 9; push($ar, &$b); $b = 5; would result in $ar[1] being equal to 5. But if you do push($ar, $b), then it would stay 9. I did a couple of tests and it seemed to work, but I do need to know if I were doing something wrong.What you did works but it's not semantically correct. You should not be changing it to is_ref but should just be incrementing the refcount as you're doing. What happens is that getParameters() as opposed to getParametersEx() keeps backwards compatibility with PHP 3.0 and split away if necessary parameters if their refcount is greater than 1. Thus, you will always your arguments with refcount = 1. If the argument is passed by reference it will be is_ref and you can just do refcount++ and it'll stay is_ref and will behave the way you want; If the argument is passed by value it won't be is_ref you can still just do refcount++ and it'll also behave the way you want (it will split away on the first write to it). I hope this explains things a bit although it's a very messy explanation. I will remove the is_ref = 1; lines now. Andi --- Andi Gutmans <andi@zend.com> ICQ: 1568297