My environment is XP, VC ++ 6.0, and installed PHP Environment
If you need to compile the extension of the current environment, you need to go to http://www.php.net/releases/to find the source code similar to php?
This is my version
First, let's take a look at this article.
Http://php.chinaunix.net/manual/zh/install.windows.building.php
Please read this article carefully and follow the instructions in this article to start the following steps:
Download 2 tools
A) Win32 compiler tools in the PHP site» http://www.php.net/extra/win32build.zip
B) the source code of the DNS parser used by PHP:» http://www.php.net/extra/bindlib_w32.zip (replace resolv. Lib in win32build.zip)
After the download is complete, add E: \ project \ app \ win32build \ bin to the path directory. Next
1. Create a working directory e: \ project \ app
2. Decompress PHP and the above two tools to the 1 directory. The final level should be like this, for example:
[Compile resovle. Lib]
Open VC ++ and bindlib. DSW, then build (F7) directly, and find resolv In the DEBUG directory. lib, copy, paste to E: \ project \ app \ win32build \ Lib, replace.
Then please refer to this article http://aiyooyoo.com/index.php/archives/212/
Let's start with (11 ).
1. Execute buildconf. bat. The effect is as follows:
2. run: cscript/nologo configure. JS -- With-PHP-build = ".. /win32build "-- without-libxml -- disable-ODBC, You can execute cscript/nologo configure. JS -- help to view help
The red lines are the files we need to compile and Expand later.
3. Run the code and add your own PHP extension (helloworld)
Then, check the ext directory and add a helloworld
4. Use VC ++ to open the helloworld project.
A) Open the php_helloworld.h file and add the following code:
PHP_FUNCTION(confirm_HelloWorld_compiled); /* For testing, remove later. */PHP_FUNCTION(PhpTestFunc);//yimiao add
B) Open the helloworld. c file and add the following two sections of code:
/* {{{ HelloWorld_functions[] * * Every user visible function must have an entry in HelloWorld_functions[]. */const zend_function_entry HelloWorld_functions[] = { PHP_FE(confirm_HelloWorld_compiled, NULL) /* For testing, remove later. */ PHP_FE(PhpTestFunc, NULL) {NULL, NULL, NULL} /* Must be the last line in HelloWorld_functions[] */};
PHP_FUNCTION(PhpTestFunc){ php_printf("this is a test function");}
C) Compile. errors may occur during compilation. For the solution, see (12) in the above article. Continue compilation. If there are still errors, the prompt is displayed.
Link: Fatal error lnk1181: cannot open input file "php5ts. lib ", find this file from the PHP environment installed on Windows, copy it to the root directory of the current source code package, and continue to compile
You need to add the directory of PHP in the "Tools" option "Directory (Library and include ).
If it doesn't happen, it's a bit strange that my DLL file does not appear in the release under hellowordl, but appears in E: \ project \ app \ php5.3 \ release_ts.
Copy the file to the ext directory of your PHP environment and open the extension. View phpinfo.
Finally, write a test page and call the function phptestfunc. OK. Now, the extension is added.