RE: [PHP] how to call user function

From: Date: Tue, 29 Aug 2000 00:40:39 +0000
Subject: RE: [PHP] how to call user function
Groups: php.general 
Request: Send a blank email to php-general+get-14029@lists.php.net to get a copy of this message
What I mean is that I want to call a user-defined C function. Say I want to know something about the client. the client side have a C function which does the query. But then how do I invoke this function in PHP script. Or let's say when user click something on the broser page, my httpd server script will actually call a API function on the client side to execute the action. How does PHP let you do that? ---Sonia > The only thing I found relevant on the PHP manual page is > call_user_function( ). There is no example of this, has anyone used it > before? I think some people must need to call user defined > function in their PHP script. Can you please help? You define a function as: Function myFunction ($inputtext) { echo $inputtext; } Then call it as: myFunction("Some text"); To output: >>> Some text call_user_func (you got the name wrong ;)) is another way to do this, so if we use the above example again, then this code: call_user_func("myFunction", "Some text"); will also output: >>> Some text This kind of thing is handy when you have self-modifying code that may create its own functions as needed and stuff like that. It's not something I've had to use in the last 3 yrs - much easier to call the function myself, or use an if..then to decide what function to call :) Jason

« previous php.general (#14029) next »