Use c to expand your php

Source: Internet
Author: User
Use c to expand your php to see how many websites are using php now. you can search for it and then you will be scared. I hope everyone will love php together. The younger brother has just learned how to expand. the calf has a try. Download php, decompress it, and cdextls finds a blue file, which indicates it is executable. ext_skel -- extnamerobert (you can name it at will here, my English name is robert). after running it, a new file will be generated, and your php will be expanded with c.

If you look at the number of websites using php, you can search for it and you will be scared. I hope everyone will love php together.

The younger brother has just learned how to expand. let's try it out.

1. Download php, decompress it, and run cd ext.

Ls

A blue file is found, which indicates that the file is executable.

./Ext_skel -- extname = robert (you can name it at will here. my english name is robert)

A new folder is generated after running.

2. Open the newly generated folder

Open the config. m4 file, find the PHP_ARG_WITH line, and remove the dnl before the three lines. dnl is the annotator.

: Wq

3. open the php_luoxin.h file, find the PHP_FUNCTION location, and add our own defined functions. we have added two new functions, luoxin and robert. the added code is:

PHP_FUNCTION (luoxin)

PHP_FUNCTION (robert)

: Wq

3. The core file in the jerry. c file is the definition file that implements the function logic. In lines around 156, refer to the confirm_jerry_compiled function to write the logic code of our new function. here is just a simple output character. a c master can write more powerful logic functions, to meet your needs.

PHP_FUNCTION (luoxin) {zend_printf ("This is luoxin function ");}

PHP_FUNCTION (robert) {zend_printf ("This is robert function ");}

Find the luoxin_functions function in the file and add the two previously set functions, luoxin and robert. the added code is:

PHP_FE (luoxin, NULL)

PHP_FE (robert, NULL)

Be sure to enter {NULL, NULL, NULL} before.

: Wq

4. Compile with phpize, which will be the same as installing memcache later

It's easy. you can use a self-written module.

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.