Can PHP and C++ pass data between each other?

后端 未结 11 1760
悲哀的现实
悲哀的现实 2020-12-14 20:36

I have a lot of mathematical calculations in my PHP script, which can be quite slow at times. I\'m wondering if it\'s possible to pass data from PHP to C++, do the calculati

11条回答
  •  北海茫月
    2020-12-14 20:50

    If you run the calculations not so often than I'd go as Oleksi says; Use PHP's exec() command to run the external C++ app which will do the work.

    But, if you run the calculations intensively, like a few times per second, then the C++ app's initial execution time might incur penalties;
    Then you could look at having a C++ service/app which listens on a socket or a file-pipe, from/to which you pass data between PHP and C++. This will save the EXE's startup time.

提交回复
热议问题