PHP development Notes Series (5)-INI file explanation ??? In JAVA development, we often use the properties file to save the configuration information required for the entire project, such as the database connection string, user name, password, and file Upload directory, in PHP, how does this configuration information be saved? This article "PHP development Notes Series (5)-INI file explanation" will be "PHP development Notes Series (XAMPP + PhpEclipse + PHP development Notes Series (5)-INI file explanation
??? In JAVA development, we often use the properties file to save the configuration information required for the entire project, such as the database connection string, user name, password, and file Upload directory, in PHP, how does this configuration information be saved? This article "PHP development Notes Series (5)-INI file explanation" will be the fifth article in the "PHP development Notes Series (XAMPP + PhpEclipse + XDebug)", which describes how to explain the INI configuration file.
??? In PHP, the INI file is usually used to save configuration information. create a variable in the INI file, and then use the parse_ini_file function to include this file in the code. This function can be easily interpreted with php. ini files in the same format.
??? For convenience, copy a php. ini file directly from the % XAMPP_HOME %/php directory to the php project to explain the experiment php script.
?
????? The INI File is short for the Initialization File, that is, the Initialization File. Is the storage format used by windows system configuration files. The INI file consists of segments, keys, and values. Section is [section], the parameter (key = value): name = value, the annotation uses a semicolon to represent (;). All the text after the semicolon until the end of the line is annotation. The following is an example of Xdebug. ini file:
?
[Xdebug]xdebug.profiler_enable=onxdebug.trace_output_dir=D:\xampp\php\tmp\xdebugxdebug.profiler_output_dir=D:\xampp\php\tmp\xdebugxdebug.remote_handler=dbgpxdebug.remote_host=localhostxdebug.remote_port=9000 xdebug.auto_trace = Onxdebug.show_exception_trace = Onxdebug.remote_autostart = Onxdebug.remote_enable = Onxdebug.collect_vars = Onxdebug.collect_return = Onxdebug.collect_params = On
?
???? The parse_ini_file () function can be used to determine whether to interpret the section fragment. the following section explains the xdebug. ini file and returns one-and two-dimensional arrays respectively:
?
File: ini1.phpurl: http: // localhost: 88/ini/ini1.php
'; Echo''; print_r($vars); echo '
'; Echo'
'; Echo''; // Access configuration information through array index (one-dimensional) echo 'xdebug. remote_host ='. $ vars ['xdebug. remote_host '].'
'; Echo 'xdebug. remote_port ='. $ vars ['xdebug. remote_port '].'
'; Echo'
';?>
?
?
File: ini2.phpurl: http: // localhost: 88/ini/ini2.php
'; Echo''; print_r($vars); echo '
'; Echo'
'; Echo''; // Access configuration information through array index (two-dimensional) echo 'xdebug. remote_host ='. $ vars ['xdebug'] ['xdebug. remote_host '].'
'; Echo 'xdebug. remote_port ='. $ vars ['xdebug'] ['xdebug. remote_port '].'
'; Echo'
';?>
?
??? Address: http://ryan-d.iteye.com/blog/1543412