Well have you tried it? Use the same example, and instead of putting "test_function", put "phpinfo", or any php function that doesn't take parameters, and see the result, it works!
To pass parameters to the function you want to call, it's a bit more complicated. Take a look at the call_user_function declaration in zend_API.h, you will see that there is one field called "parameter_count" (that's easy to understand what this is for), and the next field is "params". Those are zvals, so it's easy, put the parameters in this array as zvals, set the correct parameter count and bingo. Note that the documentation is WRONG. The call to call_user_function_ex is incorrect, it doesn't have the right number of parameters. For your case, you'd better go with call_user_function for now, not the "ex" one. Also, it should read TSRMLS_FETCH, not TSRMSLS_FETCH (don't forget this macro or you will loose the thread safe context). Fab. ----- Original Message ----- From: "Andrew Patterson" <[EMAIL PROTECTED]> To: "fabwash" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, June 16, 2002 1:38 AM Subject: Re: [PHP-DEV] Calling other PHP functions from your extension > > Take a look at http://www.php.net/manual/en/zend.calling-user-functions.php > > I guess that's what you need. > > Hmmm. I'm not sure, but I thought this was about calling user-defined > functions, not existing PHP module functions. Looking at my last email, > I probably wasn't clear enough :P I don't want to call a passed in > function name a la a callback; I want to call a core PHP function like > implode(), or explode() or mysql_connect() (for example) -- > specifically, I need to call the eval() function. Can you do that in the > manner defined for calling user functions? Are the functions explode, > implode, etc. in the user function table? I thought those just contained > the functions that had been defined by the user in the currently being > parsed script -- not all functions defined by loaded modules. Am I wrong? > > > What is your extension about? > > I'm the author/maintainer of a pair of PHP libraries named the NDBE & > the NObjects (http://ndbe.sourceforge.net); the former is a database > editor/ abstact layer library, and the latter is general 'odds and ends' > library of scripts, some of which the former requires to run. > > One such script emulates the Windows registry, providing a persistant, > filesystem-like hive/key/value system for storing information in various > formats. The scripts provides an object (NHive) that allows you to > access this 'registry', which is actually stored on the drive in a > file-tree (at a location you specify). Furthermore, we expand on the > idea of the registry to add in the concept of 'ethereal hives'. If > you're familliar with the Windows registry, picture them as sort of a > read-only hive (like HKEY_LOCAL_USER) which is only used if the > requested key/value can't be found in the *actual* hive (of the same > name). Ethereal hives sort of provide a set of default values; the first > time you ask for 'HIVE/foobar/foo', and it can't find it in the *real* > registry, it looks it up in the ethereal hive of the same name ('HIVE' > in this case). If it finds a key 'foobar' with a value 'foo', it would > return that value contained in 'foo'. If you write out a new value to > 'HIVE/foobar/foo' it will write it to the REAL registry however; and > ever after when it ask for that key ('HIVE/foobar/foo') it will give you > the value from the real registry, which you just created and set. It's a > little confusing to explain, but solves a wide variety of problems we > had with default values, and allows you to do wonderful things with > checking them in. In short, it can -- for the most part -- allow you to > do away with configuration files. > > It works very well, and we (my partners & I) have found it *very* useful > over the last couple of years, and most of the NObjects and all of the > NDBE runs on it. We had the natural idea of making it into a PHP module > more than a year ago, but none of us could find the time -- I finally > did a few days ago and was surpised how quickly it's come along. > > Of course, all of the logic is more or less written out for me; it's in > the NHive.php script :) It's just a matter or converting the code to a > somewhat lower-level language (namely C) and making it properly-cross > platform. I intend to make the Win32 version use the *actual* Windows > registry, but that's for later -- haven't ever actually *used* PHP on > Windows before. > > Anyways, that's the (long-winded) explanation. I've got 95% of the > utility functions written, I just have to do the set/get/create/delete > functions. After that, I'll be thoroughly testing it (fortunately I have > a complete library and application in the NDBE to test it on) and then > be submitting it wherever it should be submitted for consideration -- > assuming someone's interested. Otherwise, I guess it'll just be posted > on sourceforge or freshmeat :) > > Wood Shavings! > Andrew Patterson > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php