Converting C to PHP?

eozzy picture eozzy · Feb 10, 2010 · Viewed 7.7k times · Source

Is there any tool available that takes C code as input and outputs valid PHP files?

I'd like to use the SAC API but all the implementations currently available are in C, Java, Ruby and Perl. I wonder if the C implementation can be converted to PHP easily.

Answer

Pascal MARTIN picture Pascal MARTIN · Feb 10, 2010

I've never seen any tool to do that ; but the way that's generally used when one wants to use some C library from PHP is to write a PHP extension, that acts as some kind of "bridge" between the PHP userland-code, and the C library.

That's how you are able to use the curl library from PHP, for example.


A couple of interesting reads on that matter :

And, if you are really interested by the subject, and ready to spend some money on it, you could also buy the book Extending and Embedding PHP (some pages are available as preview on Google Books too) ; I've seen a couple of times that it was the book to read when interested on this subject (In fact, I've bought it some time ago, and it's an interesting read, even if you don't plan on writing an extension right now)

BTW, the author of that book is also the author of the first four articles I linked to ;-)