November 1st, 2000, 01:14 AM
I have some C functions (compiled and working in c) which i want to use in PHP. However, i dont know how to go about it. can anyone help me?? please dont tell me i have to code the entire thing all over again in php. cud u reply fast???
November 1st, 2000, 01:34 AM
What do these C functions do? Can they be called from the command line? (if so, then just use exec("/path_to_file/your_function $arguments1 $arguments2 etc..."), or one of the other PHP execution functions. See http://www.php.net/manual/function.exec.php ;The function you use depends on what you need to do with the output. This might be a quick & ugly solution, but it sounds like you are in a hurry.
Remember, PHP executes, reads, and writes files as user 'nobody', so watch your file perms.
[This message has been edited by rycamor (edited October 31, 2000).]
November 1st, 2000, 01:42 AM
thanks a lot. i can try this - however, they are not command line executable at the moment. more-over i have to get some return values from the functions. what do i do?? ( i did see the link and about the return_var variable).
November 1st, 2000, 02:01 AM
if your c program reads and writes to STDIN and STDOUT respectively, you could use a pipe instead... ie popen() etc
just a thought - don't get the impression that i've ever done anything like that before
November 1st, 2000, 02:30 AM
There's got to be some way to serialize your values to a string, return as output, and unserialize the string at the PHP end.
Also the eval() function might come in useful here.
Maybe no need to serialize; just pack everything into a string that can be eval()ed at the other end. Shouldn't be too hard .
November 2nd, 2000, 08:02 AM
why don't u create a new module..
or far more easier.. add it to for
example the strings module
it's very easy to add something..
then just recompile and user ur functions
and.. btw, what functions are these ?