简体   繁体   中英

How to integrate C++ application into PHP website?

I have a c++ application that processes a sentence and responds back to the respective user. I have a website using php that I would like to post data to this application and receive this response. Ideally, the C++ would run on the webserver and not have to be fully loaded each time it is used, but i haven't been able to get a simple 'hello world' (with cgi or c++) to work on the webserver.

What would be the easiest way to integrate a c++ application into a website? Should this work with any webhost?

To Integrate them you can take two approaches.

1) Integrate C++ as a function into PHP with http://www.php-cpp.com You can create a function, say my_complex_function, that when called in PHP, will execute a C++ code. You can read the site's documentation for information about it.

2) Keep them separate and communicate through HTTP/Pipes/Sockets/Other You could build a C++ daemon that opens up some kind of communication interface like a Socket, then with PHP you open a socket to it, send the information through the socket, and receive the answer there too. You can find socket examples for PHP here: http://php.net/manual/en/sockets.examples.php

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