C to PHP
I have some C code I need to get into a PHP web page.
I don't have a manual handy, but doesn't PHP allow you to call C code? Or Python code? You could write some wrappers that would allow you to continue using the C code in C and just return the data to PHP...
You could run your C program via cgi.
You can use the system command in PHP to call a C or any type of program. It will run in it's own shell so you need to be careful about filtering out possible mete-characters.
... I mean "meta-characters".
Check out SWIG from swig.org.
Wrap your C code in a PHP extension, then call the C code from PHP like any other PHP function.
PHP can call DLLs right? Wouldn't that be a solution?
I'm writing a hosted site, I think with a Unix O/S, but this might change. I wonder if there is anything like a translator or cross compiler? Even if imperfect and partial, this would suit me better than calling out to C code.
The best solution is going to be to re-write the C code in PHP, or move the C code to a C based CGI. Of the two, the CGI will have better execution time on a UNIX system, and be easier to maintain.
Fog Creek Home