PHP Extension: How to Use ini Variables

Source: Internet
Author: User
In extension, sometimes the value set in PHP. ini needs to be used. In PHP extension, the INI variable is used as follows:

First use:
Php_ini_begin ()
Php_ini_entry ("foo_bar.global_value", "42", php_ini_all, null)
Php_ini_entry ("foo_bar.global_string", "foobar", php_ini_all, null)
Php_ini_end ()

Php_ini_begin (), php_ini_entry (), and php_ini_end () are some macros defined by Zend. After the preceding four statements are expanded, the result is as follows:
 

Static zend_ini_entry ini_entries [] =... {// begin Definition
... {0, php_ini_all, "foo_bar.global_value", sizeof ("foo_bar.global_value"), null, "42", sizeof ("42")-1, null, 0, 0, null },
... {0, php_ini_all, "foo_bar.global_string", sizeof ("foo_bar.global_string"), null, "foobar", sizeof ("foobar")-1, null, 0, 0, null },
... {0, 0, null, 0, null, 0, 0, null}; // end definition

It can be seen that all ini variables are placed in an array of the zend_ini_entry type. The array name is ini_entries.

In this case, only such a variable is defined. to use it, you need to call it within the minit method and use
Register_ini_entries (). The macro is defined as follows: # define register_ini_entries () zend_register_ini_entries (ini_entries, module_number tsrmls_cc)

In fact, zend_register_ini_entries () is called directly for registration and tsrm is mandatory.

To ensure the clean use of these ini variables, you must clear the registered ini variables during mshutdown and use the unregister_ini_entries () macro to complete the process. The definition is as follows: # define unregister_ini_entries () zend_unregister_ini_entries (module_number tsrmls_cc)

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.