PHP Development Notes Series (v)-INI file interpretation

Source: Internet
Author: User

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

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    Tags Index: