PHP development Notes Series (5)-INI file explanation

Source: Internet
Author: User
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 + xd 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

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.