PHP extension development entry, php extension entry _ PHP Tutorial

Source: Internet
Author: User
Tags getting started with php
PHP extension development entry, php extension entry. PHP extension development entry, php extension entry: www. orlion. ga1090 write a function that converts all strings to uppercase :? Phpfunctionmy_toupper ($ str) {getting started with returnstrtoupp PHP extension development and getting started with php extension

Original article:Http://www.orlion.ga/1090/

Write a simple function that converts all strings into uppercase letters:

 

Now we develop a php extension to implement the my_toupper function.

Step 1:

PHP provides an extension framework generator: ext_skel, which is in the ext directory of php source code (my is/usr/local/src/php-5.6.17/ext. First, create an orlion. skel file in the ext Directory of the php source code. the file content is:

string my_toupper(string str)

This file tells ext_skel that our extension contains the my_toupper function. then, execute:

./ext_skel --extname=orlion --proto=orlion.skel

In this step, an orlion folder is created under the current directory. The directory structure is as follows:

At this time, the extended framework is ready.

Step 2:

Modify config. m4 in the orlion directory and remove the dnl of lines 10th, 11, and 12 of this file:

Is

Changed:

Step 3:

Next we need to implement our function. open orlion. c, find the function PHP_FUNCTION (my_toupper), and modify it to the following:

Then compile the extension and run the following commands in sequence:

$ /usr/local/php/bin/phpize$ ./configure --with-php-config=/usr/local/php/bin/php-config$ make

Step 4:

Add the extension to php. first, copy orlion/mudules/orlion. so in our extension to the extension directory of php:

Modify the configuration of php. ini and add "extension = orlion. so" to the end of the file, and then restart php-fpm.

Step 5:

Write a test. php file and test it:

 

Run the command and you can see that ABC and success are output!

Access to PHP kernel technologies: http://www.orlion.ga/tag/php-internal/

Http://www.orlion.ga/1090/ to write a simplest function to convert all strings into uppercase :? Phpfunctionmy_toupper ($ str) {returnstrtoupp...

Related Article

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.