[PHP] 嵌入式PHP →→→→→进入此内容的聊天室

来自 , 2021-04-05, 写在 PHP, 查看 153 次.
URL http://www.code666.cn/view/326fb04c
  1. #include <sapi/embed/php_embed.h>
  2. #ifdef ZTS
  3.    void ***tsrm_ls;
  4. #endif
  5. /* Extension bits */
  6. zend_module_entry php_mymod_module_entry = {
  7.     STANDARD_MODULE_HEADER,
  8.     "mymod", /* extension name */
  9.     NULL, /* function entries */
  10.     NULL, /* MINIT */
  11.     NULL, /* MSHUTDOWN */
  12.     NULL, /* RINIT */
  13.     NULL, /* RSHUTDOWN */
  14.     NULL, /* MINFO */
  15.     "1.0", /* version */
  16.     STANDARD_MODULE_PROPERTIES
  17. };
  18. /* Embedded bits */
  19. static void startup_php(void)
  20. {
  21.     int argc = 1;
  22.     char *argv[2] = { "embed5", NULL };
  23.     php_embed_init(argc, argv PTSRMLS_CC);
  24.     zend_startup_module(&php_mymod_module_entry);
  25. }
  26. static void execute_php(char *filename)
  27. {
  28.     zend_first_try {
  29.         char *include_script;
  30.         spprintf(&include_script, 0, "include '%s'", filename);
  31.         zend_eval_string(include_script, NULL, filename TSRMLS_CC);
  32.         efree(include_script);
  33.     } zend_end_try();
  34. }
  35. int main(int argc, char *argv[])
  36. {
  37.     if (argc <= 1) {
  38.         printf("Usage: embed4 scriptfile";);
  39.         return -1;
  40.     }
  41.     startup_php();
  42.     execute_php(argv[1]);
  43.     php_embed_shutdown(TSRMLS_CC);
  44.     return 0;
  45. }
  46.  

回复 "嵌入式PHP"

这儿你可以回复上面这条便签

captcha