Home >Backend Development >PHP Tutorial >define Installation and use of hidef, a PHP extension that improves define performance
Official website: http://pecl.php.net/package/hidef
Introduction:
Allow definition of user defined constants in simple ini files, which are then processed like internal constants, without any
of the usual performance penalties.
Allow definition Simple ini files to define the required constants, just like using internal variables, and without the performance issues of using Define.
The author said Hidef is initialized in php module init, before apache starts spawning children.
Before apache starts, these constants are created and initialized when PHP starts, so there is no need to define constants in php, and there will be no performance problems. !
It is also available under Nginx. The following is the installation process:
1. Download and unzip it into the directory
# wget http://pecl.php.net/get/hidef-0.1.8.tgz
# tar zxvf hidef-0.1. 8.tgz
# cd hidef-0.1.8
2. There is no configure file, execute phpize to create the file
# /usr/local/webserver/php/bin/phpize
# ./configure --enable-hidef --with -php-c/local/webserver/php/bin/php-config
# make
# make install
3. Add to the php.ini file
# vi /usr/local/webserver/php/etc/php.ini
-------------------------------------------------
extension =hidef.so
hidef.ini_path=/usr/local/webserver/php/etc/
-------------------------------- --------------------------------------------------
Note that if hidef.ini_path is not defined in the php.ini file, the default .ini file reading location is /hidef. You only need to manually create the file vi /hidef/hidef.ini.
# vi /usr/local/webserver/php/etc/hidef.ini (Adjust the path here according to the situation)
Copy the code The code is as follows:
[hidef]
int ANSWER = 42;
str HX = "9enjoy";
float PIE = 3.14159;