February 26, 2015 15:44:41
Reason: Want to use PHP to implement a filter algorithm, which to use in place operation, but PHP's built-in int type does not give force, can not support the bit operation of large integers
Once the data is too large, it becomes a floating-point number, floating-point numbers cannot participate in bit operations ... Also tried Nodejs, Redis is not. With Java, you have to take the environment.
Just want to use the PHP extension, C to achieve
The first step: using PHP commands to automatically generate the extension framework
Enter the source code directory of PHP and enter the EXT directory
./ext_skel--extname=zzbbloom
Step Two: Modify the framework to add your own function code
The frame that was built in the previous step is actually a folder named Zzbbloom, and in/path/to/php/src/ext/zzbbloom/, go to the folder
1) Edit the Config.m4 file (the "DNL" at the beginning of each line of the file is the comment) and find the php_arg_enable (Zzbbloom, ...). In these lines, remove the DNL string from the front:
1 php_arg_enable (Zzbbloom, whether to ENABLE zzbbloom support,2 [ --enable-zzbbloom enable zzbbloom support])
2) edit zzbbloom.h zzbbloom.c file add your own function (can also be automatically generated by the framework function, confirm_zzbbloom_compiled ())
Reference: Http://www.jb51.net/article/16791.htm http://www.open-open.com/lib/view/open1340585955030.html
Step three: Compiling
First go inside the generated framework directory, then execute the phpize command, then execute the./configure command, final make, make install
1 cd path/to/php/srccode/ext/zzbbloom/2 /usr/local/php/bin/pphpize//This command generates configure Makefile and other documents 3 ./configure--with-php-config=/usr/local/php/bin/php-config4 make5makeinstall
Fourth step: Restart PHP-FPM, Nginx
Reference: http://www.cnblogs.com/iLoveMyD/p/4301429.html
Fifth Step: Test
1 Var_dump (Get_loaded_extensions ()); 2 var_dump (Get_extension_funcs ('zzbbloom')); 3 echo confirm_zzbbloom_compiled (' my first php extension, haha haha ');
On the development of PHP extension