J S
J S

Reputation: 3496

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!

Upvotes: 2

Views: 1174

Answers (2)

user2249683
user2249683

Reputation:

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

Upvotes: 1

Abesalomi Gogatishvili
Abesalomi Gogatishvili

Reputation: 193

Try this

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

Upvotes: 2

Related Questions