Expand your php
- Expand your php
- Three extension methods
- Extension dll extension
- Summary
First of all, note that all of the following operations are performed under win, using the tool VC ++ 6.0.
Expand your PHP
PHP plays an important role in web System Development with a convenient and fast style. PHP itself provides a wide range of functions and functions. Let's talk about it. Let's look at how we expand it.
Three extension methods
- External Modules
- Built-in Modules
- The Zend Engine
For the advantages and disadvantages of the three methods, see the PHP Manual: http://www.php.net/manual/en/zend.possibilities.php
Extension dll
1. First, let's go to the next php source. We can see the following important directories. Ext, main, TSRM, Zend. In addition, we may also need bindlib_w32 (you need to go up and down from cvs) and php4ts. lib under the PHP Directory.
2. Open VC and create a Win32 Dynamic-Link Library, such:
3. Click OK, select "An Empty Dll Project", and click Finish.
4. Set the Active Configuration of Build and select Release :)
5. Project-> settings
The predefined identity is as follows:
ZEND_DEBUG = 0, COMPILE_DL_BINZY, ZTS = 1, ZEND_WIN32, PHP_WIN32, HAVE_BINZY = 1
This is the inclusion path. You can add the paths mentioned above.
Select Multithreaded DLL.
Link php4ts. lib ~~
O, forget to add the/Tc parameter:
6. write code.
Build a head and a body.
Binzy. h
// Binzy Wu
// 2004-4-9
// PHP Extension
# If HAVE_BINZY
Extern zend_module_entry binzy_module_entry;
# Define binzy_module_ptr & binzy_module_entry
PHP_FUNCTION (hellobinzy );//
PHP_MINFO_FUNCTION (binzy );//
# Endif
Binzy. c
// Binzy Wu
// 2004-4-9
// PHP Extension
# Include "php. h"
# Include "Binzy. h"
# If HAVE_BINZY
# If COMPILE_DL_BINZY
ZEND_GET_MODULE (binzy)
# Endif
Function_entry binzy_functions [] = {
PHP_FE (hellobinzy, NULL)
{NULL, NULL, NULL}
};
Zend_module_entry binzy_module_entry = {
STANDARD_MODULE_HEADER,
"Binzy", binzy_functions, NULL, PHP_MINFO (binzy), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
};
PHP_MINFO_FUNCTION (binzy)
{
Php_info_print_table_start ();
Php_info_print_table_row (2, "Binzy Extension", "Enable ");
Php_info_print_table_end ();
}
PHP_FUNCTION (hellobinzy)
{
Zend_printf ("Hello Binzy ");
}
# Endif
7. Compile, modify php. ini, restart apache, and write a php
<? Php
Hellobinzy ();
?>
Hoho ~~~
Phpinfo ();
Summary
This is an entry-level article, and we will try again later ~~. I don't know much about it. I am a beginner.