3

I have the usual PHP and MYSQL server running but I want to perform some CPU intensive computations. Therefore I wish to run a C program to handle that part.

Is it possible to exchange data between a PHP and a C/C++ program on the server itself?

Regards PP

Pranjal
  • 299
  • 3
  • 10
  • 2
    [This](http://stackoverflow.com/questions/2152584/is-there-anything-like-pythons-ctype-for-php-accessing-libraries-without-the-n) may answer your question. – Cairnarvon Mar 02 '13 at 21:44

3 Answers3

2

Why not write a C++ program and then use popen to fetch the results when it is executed.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
2

It's possible and you have multiple ways to achieve that.

  • write an extension (as it was already suggested)
  • call your C program with 'exec()'
  • use Gearman
  • run C program as a service and communicate with it via pipe or a socket

From the above I would choose an extension or Gearman.

Lukasz Kujawa
  • 3,026
  • 1
  • 28
  • 43
1

Write an extension :)

PHP extension wrapper for C++

#include "php.h"
Community
  • 1
  • 1
sent1nel
  • 1,580
  • 1
  • 15
  • 31