Getting started with extending your PHP

Source: Internet
Author: User
Getting started with extending your PHP Expand Your php

  1. Expand Your php
  2. Three extension methods
  3. Extension dll extension
  4. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.