All,
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as follows:
---------- 8< -------------------- 8< ----------
static
ZEND_BEGIN_ARG_INFO(all_args_prefer_ref, ZEND_SEND_PREFER_REF)
ZEND_END_ARG_INFO()
zend_function_entry shorthand_functions[] = {
PHP_FE(filled, all_args_prefer_ref)
{NULL, NULL, NULL} /* Must be the last line in
shorthand_functions[] */
};
PHP_FUNCTION(filled)
{
RETURN_TRUE;
}
---------- 8< -------------------- 8< ----------
Then, in PHP I try the following test code:
---------- 8< -------------------- 8< ----------
<?php
$x = array();
$x["dog"] = "spot";
$x["cat"] = "moriss";
print_r($x);
// testing
print filled("testing", $x["pig"], $y->testing);
print "\n";
print_r($x);
print_r($y);
?>
---------- 8< -------------------- 8< ----------
Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
---------- 8< -------------------- 8< ----------
Array
(
[dog] => spot
[cat] => moriss
)
1
Array
(
[dog] => spot
[cat] => moriss
[pig] =>
)
stdClass Object
(
[testing] =>
)
---------- 8< -------------------- 8< ----------
Is there a way to define the parameters which an extension's function
will accept to be optionally set? The prefer-by-ref I am using is
making the var exist even when I don't want it to.
Dante
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php