简体   繁体   中英

Run PHP Script From C++

I can find a lot of information on running C++ programs from PHP, but not the other way around. I want to run a PHP script from C++, which will perform some calculations and then use "echo" for output. The C++ program should wait to receive the output from the PHP script and parse it before continuing.

Thanks!

Try this

#include <cstdlib>
int main(){
   system("php file.php");
   return 0;
}

You could utilize a pipe and run 'php script.php'. An annoying example for a pipe in windows (full of boilerplate) is at http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499%28v=vs.85%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM