<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>[PHP-DEV] call user defined function with args</title>
        <description> Hello,

I found this zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache
*fci_cache TSRMLS_DC) and many examples using it. I can successfully call
this and it will call the user function for me. I'm interested in learning
how to not only call the function, but also pass arguments to that function.

Can anyone please point me to where I can see how that's done?

thx</description>
        <link>http://www.serverphorums.com/read.php?7,486725,486725#msg-486725</link>
        <lastBuildDate>Wed, 22 May 2013 10:54:04 +0200</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,487518#msg-487518</guid>
            <title>Re: [PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,487518#msg-487518</link>
            <description><![CDATA[ On Sat, Apr 28, 2012 at 3:15 PM, Nikita Popov &lt;nikita.ppv@googlemail.com&gt;wrote:<br />
<br />
&gt; On Sat, Apr 28, 2012 at 11:49 PM, Yader Hernandez<br />
&gt; &lt;yader.hernandez@gmail.com&gt; wrote:<br />
&gt; &gt; I had a look at<br />
&gt; &gt;<br />
&gt; <a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
&gt; &gt; and<br />
&gt; &gt; I don't understand how it's passing the arguments into the closure given<br />
&gt; by<br />
&gt; &gt; the user.<br />
&gt; &gt;<br />
&gt; &gt; I can successfully call the closure given, but passing arguments into the<br />
&gt; &gt; closure is something I'm not clear on.<br />
&gt; &gt;<br />
&gt; &gt; Can someone please shed some light?<br />
&gt;<br />
&gt; Look at the zend_parse_parameters call. It fetches the params into<br />
&gt; fci.params and their number into fci.param_count.<br />
&gt;<br />
&gt; zend_fcall_info.params is defined as zval***, so it's basically an<br />
&gt; array of zval**. So you simply have to create one with your arguments<br />
&gt; :)<br />
&gt;<br />
&gt; Hope that helps,<br />
&gt; Nikita<br />
&gt;<br />
<br />
Ah! Great it works now. Thanks!<br />
<br />
I'm assuming that return_value in this case is being used as whatever the<br />
closure returned  ?<br />
<br />
ie. function ($element) { return false; }<br />
<br />
then that means I can do Z_LVAL_P(return_value) /* 0 */, correct ?]]></description>
            <dc:creator>Yader Hernandez</dc:creator>
            <category>php-internals</category>
            <pubDate>Sun, 29 Apr 2012 00:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,487512#msg-487512</guid>
            <title>Re: [PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,487512#msg-487512</link>
            <description><![CDATA[ On Sat, Apr 28, 2012 at 11:49 PM, Yader Hernandez<br />
&lt;yader.hernandez@gmail.com&gt; wrote:<br />
&gt; I had a look at<br />
&gt; <a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
&gt; and<br />
&gt; I don't understand how it's passing the arguments into the closure given by<br />
&gt; the user.<br />
&gt;<br />
&gt; I can successfully call the closure given, but passing arguments into the<br />
&gt; closure is something I'm not clear on.<br />
&gt;<br />
&gt; Can someone please shed some light?<br />
<br />
Look at the zend_parse_parameters call. It fetches the params into<br />
fci.params and their number into fci.param_count.<br />
<br />
zend_fcall_info.params is defined as zval***, so it's basically an<br />
array of zval**. So you simply have to create one with your arguments<br />
:)<br />
<br />
Hope that helps,<br />
Nikita<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Nikita Popov</dc:creator>
            <category>php-internals</category>
            <pubDate>Sun, 29 Apr 2012 00:20:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,487508#msg-487508</guid>
            <title>Re: [PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,487508#msg-487508</link>
            <description><![CDATA[ On Fri, Apr 27, 2012 at 1:06 AM, jpauli &lt;jpauli@php.net&gt; wrote:<br />
<br />
&gt; You might be interested by zend_call_method_with_[XXX]_params() as<br />
&gt; well <a href="http://lxr.php.net/xref/PHP_5_3/Zend/zend_interfaces.h" target="_blank"  rel="nofollow">http://lxr.php.net/xref/PHP_5_3/Zend/zend_interfaces.h</a><br />
&gt;<br />
&gt; Julien.Pauli<br />
&gt;<br />
&gt; On Fri, Apr 27, 2012 at 8:51 AM, Laruence &lt;laruence@php.net&gt; wrote:<br />
&gt; &gt; Hi:<br />
&gt; &gt;  you can refer to zif_call_user_func, which could be find at<br />
&gt; &gt;<br />
&gt; <a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
&gt; &gt;<br />
&gt; &gt; thanks<br />
&gt; &gt;<br />
&gt; &gt; On Fri, Apr 27, 2012 at 12:43 PM, Yader Hernandez<br />
&gt; &gt; &lt;yader.hernandez@gmail.com&gt; wrote:<br />
&gt; &gt;&gt; Hello,<br />
&gt; &gt;&gt;<br />
&gt; &gt;&gt; I found this zend_call_function(zend_fcall_info *fci,<br />
&gt; zend_fcall_info_cache<br />
&gt; &gt;&gt; *fci_cache TSRMLS_DC) and many examples using it. I can successfully<br />
&gt; call<br />
&gt; &gt;&gt; this and it will call the user function for me. I'm interested in<br />
&gt; learning<br />
&gt; &gt;&gt; how to not only call the function, but also pass arguments to that<br />
&gt; function.<br />
&gt; &gt;&gt;<br />
&gt; &gt;&gt; Can anyone please point me to where I can see how that's done?<br />
&gt; &gt;&gt;<br />
&gt; &gt;&gt; thx<br />
&gt; &gt;<br />
&gt; &gt;<br />
&gt; &gt;<br />
&gt; &gt; --<br />
&gt; &gt; Laruence  Xinchen Hui<br />
&gt; &gt; <a href="http://www.laruence.com/" target="_blank"  rel="nofollow">http://www.laruence.com/</a><br />
&gt; &gt;<br />
&gt; &gt; --<br />
&gt; &gt; PHP Internals - PHP Runtime Development Mailing List<br />
&gt; &gt; To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a><br />
&gt; &gt;<br />
&gt;<br />
<br />
I had a look at<br />
<a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
and<br />
I don't understand how it's passing the arguments into the closure given by<br />
the user.<br />
<br />
I can successfully call the closure given, but passing arguments into the<br />
closure is something I'm not clear on.<br />
<br />
Can someone please shed some light?]]></description>
            <dc:creator>Yader Hernandez</dc:creator>
            <category>php-internals</category>
            <pubDate>Sat, 28 Apr 2012 23:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,486800#msg-486800</guid>
            <title>Re: [PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,486800#msg-486800</link>
            <description><![CDATA[ You might be interested by zend_call_method_with_[XXX]_params() as<br />
well <a href="http://lxr.php.net/xref/PHP_5_3/Zend/zend_interfaces.h" target="_blank"  rel="nofollow">http://lxr.php.net/xref/PHP_5_3/Zend/zend_interfaces.h</a><br />
<br />
Julien.Pauli<br />
<br />
On Fri, Apr 27, 2012 at 8:51 AM, Laruence &lt;laruence@php.net&gt; wrote:<br />
&gt; Hi:<br />
&gt;  you can refer to zif_call_user_func, which could be find at<br />
&gt; <a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
&gt;<br />
&gt; thanks<br />
&gt;<br />
&gt; On Fri, Apr 27, 2012 at 12:43 PM, Yader Hernandez<br />
&gt; &lt;yader.hernandez@gmail.com&gt; wrote:<br />
&gt;&gt; Hello,<br />
&gt;&gt;<br />
&gt;&gt; I found this zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache<br />
&gt;&gt; *fci_cache TSRMLS_DC) and many examples using it. I can successfully call<br />
&gt;&gt; this and it will call the user function for me. I'm interested in learning<br />
&gt;&gt; how to not only call the function, but also pass arguments to that function.<br />
&gt;&gt;<br />
&gt;&gt; Can anyone please point me to where I can see how that's done?<br />
&gt;&gt;<br />
&gt;&gt; thx<br />
&gt;<br />
&gt;<br />
&gt;<br />
&gt; --<br />
&gt; Laruence  Xinchen Hui<br />
&gt; <a href="http://www.laruence.com/" target="_blank"  rel="nofollow">http://www.laruence.com/</a><br />
&gt;<br />
&gt; --<br />
&gt; PHP Internals - PHP Runtime Development Mailing List<br />
&gt; To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a><br />
&gt;<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>jpauli</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 27 Apr 2012 10:10:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,486776#msg-486776</guid>
            <title>Re: [PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,486776#msg-486776</link>
            <description><![CDATA[ Hi:<br />
  you can refer to zif_call_user_func, which could be find at<br />
<a href="http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714" target="_blank"  rel="nofollow">http://lxr.php.net/opengrok/xref/PHP_5_4/ext/standard/basic_functions.c#4714</a><br />
<br />
thanks<br />
<br />
On Fri, Apr 27, 2012 at 12:43 PM, Yader Hernandez<br />
&lt;yader.hernandez@gmail.com&gt; wrote:<br />
&gt; Hello,<br />
&gt;<br />
&gt; I found this zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache<br />
&gt; *fci_cache TSRMLS_DC) and many examples using it. I can successfully call<br />
&gt; this and it will call the user function for me. I'm interested in learning<br />
&gt; how to not only call the function, but also pass arguments to that function.<br />
&gt;<br />
&gt; Can anyone please point me to where I can see how that's done?<br />
&gt;<br />
&gt; thx<br />
<br />
<br />
<br />
-- <br />
Laruence  Xinchen Hui<br />
<a href="http://www.laruence.com/" target="_blank"  rel="nofollow">http://www.laruence.com/</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Laruence</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 27 Apr 2012 09:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,486725,486725#msg-486725</guid>
            <title>[PHP-DEV] call user defined function with args</title>
            <link>http://www.serverphorums.com/read.php?7,486725,486725#msg-486725</link>
            <description><![CDATA[ Hello,<br />
<br />
I found this zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache<br />
*fci_cache TSRMLS_DC) and many examples using it. I can successfully call<br />
this and it will call the user function for me. I'm interested in learning<br />
how to not only call the function, but also pass arguments to that function.<br />
<br />
Can anyone please point me to where I can see how that's done?<br />
<br />
thx]]></description>
            <dc:creator>Yader Hernandez</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 27 Apr 2012 06:50:02 +0200</pubDate>
        </item>
    </channel>
</rss>
