VC製作USBWebserver v8.6 [PHP 元件(dll)]
VC製作USBWebserver v8.6 [PHP 元件(dll)]
資料來源: https://my.oschina.net/yushulx/blog/467293
http://www.dreamincode.net/forums/topic/244215-introduction-to-creating-a-php-extension-for-windows/
http://www.itread01.com/articles/1478578234.html
GITHUB:https://github.com/jash-git/VC-create-PHP-extensions-object
PHPTest.h
#pragma once
#ifdef PHP_WIN32
#ifdef ZTS
PHP_MINIT_FUNCTION(PHPTest);
// PHP_FUNCTION 用於定義要導出給php調用的函數名稱,這裏我們定義了3個函數:init_module,test_module, close_module
PHP_FUNCTION(init_module);
/* In every utility function you add that needs to use variables
#ifdef ZTS |
PHPTest.cpp
// PHPTest.cpp : 定義 DLL 應用程式的匯出函式。 #include “stdafx.h”
// 聲明以下的宏定義解決在編譯過程中會發生:error C2466: 不能分配常量大小為0 的數組的錯誤。
// #include “XXXXX.h” 在以下包含頭文件的前面包含要用到的c++ 的stl的頭文件,或者你自己寫的C++的頭文件。
extern “C” {
zend_module_entry PHPTest_module_entry = {
PHP_MINIT_FUNCTION(PHPTest)
PHP_MSHUTDOWN_FUNCTION(PHPTest)
PHP_RINIT_FUNCTION(PHPTest)
PHP_RSHUTDOWN_FUNCTION(PHPTest)
PHP_MINFO_FUNCTION(PHPTest)
// 以下是php導出函數的實現,比如string init_module(string content)
// 以下是int test_module(string content)函數的實現
// 以下是 void close_module()函數的實現 |
PHPTest_dll.php
<?php echo init_module(‘test init’); echo'<br>’; //輸出: test init echo test_module(‘test_module’); echo'<br>’; close_module(); ?> |
One thought on “VC製作USBWebserver v8.6 [PHP 元件(dll)]”
PHP VC++(C/C++) 元件 DLL 開發 環境 相依檔案 下載
http://windows.php.net/downloads/releases/archives/
======================
VC++[2005~2022] 各版本 Run Time(VC Run Time-vc_redist)
GITHUB: https://github.com/jash-git/VC-Run-Time-vc_redist