PHP Development Note Series (v)-INI file explanation
??? In Java development, we often use the properties file to save the entire project needs to use the configuration information, such as database connection string, user name, password, file upload directory and so on, then how to save the configuration information in PHP? This article, "PHP Development Note Series (v)-INI file Interpretation", will be the fifth of the PHP Development Note Series (XAMPP+PHPECLIPSE+XDEBUG), which explains how to interpret the INI configuration file.
??? In PHP, you typically use the INI file to save configuration information, create a variable in an. ini file, and then include the file in your code with the Parse_ini_file function, which am hesitant enough to interpret files in the same format as php.ini.
??? For the sake of convenience, copy a copy of the php.ini file from the%xampp_home%/php directory to the PHP project, and experiment with the PHP script's interpretation.
?
????? INI file is an abbreviation for the initialization file, which is the initialization files. is the storage format used by the system configuration file for Windows. INI file consists of sections, keys, and values. sections are [section], parameters (key = value):name=value, and annotations are denoted with semicolons (;). The text after the semicolon, until the end of the line is all annotations. The following is a sample 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 set whether to interpret section fragments, the above Xdebug.ini files are interpreted to return one and two-dimensional arrays, respectively:
?
file:ini1.phpurl:http://localhost:88/ini/ini1.php
INI File Content:
'; Echo ''; Print_r ($vars); Echo '
'; Echo '
'; Echo ''; Access configuration information through an 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
INI File Content:
'; Echo ''; Print_r ($vars); Echo '
'; Echo '
'; Echo ''; Access configuration information through an array index (two-dimensional) echo ' xdebug.remote_host= '. $vars [' Xdebug '] [' xdebug.remote_host ']. '
'; Echo ' xdebug.remote_port= '. $vars [' Xdebug '] [' xdebug.remote_port ']. '
'; Echo '
';?>
?
??? This address: http://ryan-d.iteye.com/blog/1543412