Reusing PHP string value pointers
| From: | Marshall A. Greenblatt | Date: | Thu, 28 Nov 2002 00:50:03 +0000 |
| Subject: | Reusing PHP string value pointers | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-91853@lists.php.net to get a copy of this message | ||
Apologies in advance if this is the wrong mailing list. Please direct me to
a more appropriate mailing list if there is one :-)
When a PHP string variable is changed via a PHP script, such as:
$foo = 'new value';
what happens to the `value.str.val' pointer internally? Is it possible to
have the new value assigned to the same `value.str.val' pointer that the
variable is currently using instead of having that pointer replaced by a
pointer to the new value?
I have an internal function that binds to a particular pointer address, from
which it reads data at a later point. I'd like to allow the value at that
address to be modified by assignment from within a PHP script.
The following PHP pseudocode is a simple example of this concept:
$foo = 'my value';
bind_value(&$foo); // a pointer to foo's value is stored internally.
print_value(); // output 'my value', which is the current value of the
pointer.
$foo = 'a new value';
print_value(); // output 'a new value', which is the new value of the
pointer.
In other words, I need the new value copied to the same pointer address as
the old value. I know that it's possible to retrieve the value of a variable
via a hash/list lookup on the variable name, but the pointer is being passed
to a function outside the scope of this module, and that function expects it
to "just work" with a pre-designated string pointer. Any suggestions and/or
clarification would be greatly appreciated.
Thanks,
Marshall