Getting started with extending your PHP
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,NULL,NULL,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
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.