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...