PHP configuration file _ the most common ini functions of PHP

Source: Internet
Author: User
Php configuration functions are several ini _ * functions. if the configuration file is manipulated for the next time, there are actually four functions: ini_get, ini_set, ini_get_all, and ini_restore. Groups think that ini_set and ini_get are the most useful.

Php configuration functions are several ini _ * functions. if the configuration file is manipulated for the next time, there are actually four functions: ini_get, ini_set, ini_get_all, and ini_restore. Groups think that ini_set and ini_get are the most useful.

* Ini_get (): gets the option value of the configuration file.

Many people believe this function is used to obtain the value of an option in the configuration file. if it is true, it goes to 1. if it is false, it goes to 0, and the string goes to the string.

For example, in the manual:

<? Php/* Our php. ini contains the following settings: display_errors = Onregister_globals = Offpost_max_size = 8 M */echo 'display _ errors = '. ini_get ('display _ errors '). "\ n"; // whether the echo 'register _ globals = 'can be opened when an error occurs '. ini_get ('register _ globals '). "\ n"; // whether the global variable can open echo 'post _ max_size = '. ini_get ('post _ max_size '). "\ n"; // maximum file size that can be submitted echo 'post _ max_size + 1 = '. (ini_get ('post _ max_size ') + 1 ). "\ n";?>

Input:

display_errors = 1register_globals = 0post_max_size = 8Mpost_max_size+1 = 9

This function can be easily manipulated to obtain the configuration file. For example, if you want to manipulate string filtering, but it is not clear whether magic_quotes_gpc has been opened, you can write a function like this:

/* String filter function */function stringFilter ($ str) {if (ini_get ('Magic _ quotes_gpc) ') {return $ str ;} else {return addslashes ($ str );}}

Of course, if you cannot know whether your global variables can be opened, you can also customize such functions:

/* Variable detection function */function getGetVar ($ var) {if (ini_set ('register _ gobals ') {return $ var ;} else {return $ _ GET ['var'];}

Of course, you can do a lot of useful work and I will gradually understand it.



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.