Calling C/C++ library function from PHP

前端 未结 5 1612
余生分开走
余生分开走 2020-11-27 16:50

We have a PHP web app running on a customer\'s machine. For an update, we have a bit of code in C that we\'d like to include as a native opaque library along with the PHP we

相关标签:
5条回答
  • 2020-11-27 17:34

    You can use ZEND to plug your C code into PHP.

    http://php.net/manual/en/internals2.ze1.zendapi.php

    0 讨论(0)
  • 2020-11-27 17:36

    Take a look at some of the Zend tutorials on Extension writing, this one in particular "Wrapping C++ Classes in a PHP Extension"

    0 讨论(0)
  • 2020-11-27 17:39

    The answer by St. John Johnson is correct. But you can now also us the php-cpp library. It offers a much easier bridge between PHP and C++. See http://www.php-cpp.com for more information.

    0 讨论(0)
  • 2020-11-27 17:48

    You can compile your code and use system, shell_exec or passthru functions to handle the output. Most web hosts allow you to compile c++ code, just ssh to your server, upload the code and compile it.

    0 讨论(0)
  • 2020-11-27 17:51

    Another option is to have the C code as a daemon, always running, and the php script connect to it throught unix domain sockets or some existing library to exchange data.

    More info here

    0 讨论(0)
提交回复
热议问题