[PHP Learning Tutorial-System]004. Ini_set () To set system properties (Ini_set Method)

Source: Internet
Author: User

PHP Intent: ini_set-setting values for a system configuration item

Basic information:

String ini_set (String $varname, String $newvalue).
(Description: Sets the value for the specified configuration option.) This option keeps the new value when the script is run and resumes at the end of the script. )

Parameters:

Varname-the system entry name. (not all valid options can be changed with Ini_set ().) Here is an appendix to the list of valid options. )

The new value of the newvalue-option.

return value:

Returns the old value on success, FALSEon failure.

Example

Determines whether the error display is enabled, and if not set, sets the error display.

Example 1:

<? PHP Echo Ini_get (' display_errors '); if (! Ini_get (' Display_errors ')) {    ini_set(' display_errors ', ' 1 ');} Echo Ini_get (' display_errors ');? >

Note:

First parameter: variable name in the configuration file
Second parameter: The value to be assigned.

For example, there is a line in the config file: path= '
So Ini_set (' path ', ' C:\Windows ') is the function of changing this line to Path= ' C:\Windows '

Extending content

PHP's Ini_set function is the value in the SET option, which takes effect after executing the function, and this setting fails at the end of the script .

Note: not all options can be changed by the function set . The specific values can be set and the list in the manual can be viewed.

Application One:

The Display_error option is off, but you want to display the error message in the program, so that you can debug the program, then use the PHP ini_set function:

Ini_set ("Display_errors", "on");

Then the program on your page will display an error message, and you can also use error_reporting to set the level of error messages displayed.

Application Two:

If you need to increase the script execution time, you can set:

Ini_set ("Max_execution_time",  "180");

Then the script execution time is changed from the default of 30 seconds to 180 seconds, of course, you can also use Set_time_limit () to set.

Apply Three (*):

In fact, you put PHP ini_set function and ini_get combination so that, very good. For example, if you want to add your own file path to the config file, but you have no permission to change php.ini, you can combine two functions:

Ini_set (' include_path ',  Ini_get (' include_path '). ':/your_include_dir: ');

Conclusion

The "Application Three" in the above extension content is a must kill skill that we break the service side permission and extension limit, you know? Is you OK?

Not finished, waiting to be updated ...

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4824389.html

[PHP Learning Tutorial-System]004. Ini_set () To set system properties (Ini_set Method)

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.