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

后端 未结 11 1764
悲哀的现实
悲哀的现实 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 21:01

    You can do this, and this is a common solution to improve performance of performance-critical code. You can create a command line application in C++, and execute it using PHP's exec command (or something similar).

    As for passing data, you have a few options. If it's a lot of data, you can put it in a file using PHP, and access that file from C++. If it's less data, you can simply pass in command line arguments when you run the C++ program.

提交回复
热议问题