Home  >  Article  >  Backend Development  >  Introduction to the specific usage of PHP configuration function ini_get()_PHP tutorial

Introduction to the specific usage of PHP configuration function ini_get()_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:31:04966browse

Output:

  1. display_errors = 1
  2. register_globals = 0
  3. post_max_size = 8M
  4. post_max_size+1 = 9

PHP configuration function ini_get() is mainly used to obtain the configuration file, which can be a lot more convenient for you operate. For example, you want to operate string filtering, but you don’t know whether magic_quotes_gpc is turned on, so you can write a function like this:

<ol class="dp-xml">
<li class="alt"><span><span>/* 字符串过滤函数 */  </span></span></li>
<li><span>function stringFilter($str)  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>if (ini_get(’magic_quotes_gpc)’) </span></li>
<li><span>{  </span></li>
<li class="alt"><span>return $str;  </span></li>
<li><span>} </span></li>
<li><span>else {  </span></li>
<li class="alt"><span>return addslashes($str);  </span></li>
<li><span>}  </span></li>
<li class="alt"><span>} </span></li>
</ol>

Of course, if You have no way of knowing whether your global variables are open, or you can customize a function like this:

<ol class="dp-xml">
<li class="alt"><span><span>/* 变量检测函数 */  </span></span></li>
<li><span>function getGetVar($var)  </span></li>
<li class="alt"><span>{  </span></li>
<li><span>if (ini_set(’register_gobals’))</span></li>
<li><span>{  </span></li>
<li class="alt"><span>return $var;  </span></li>
<li><span>} </span></li>
<li><span>else {  </span></li>
<li class="alt"><span>return $_GET['var'];  </span></li>
<li><span>}  </span></li>
<li class="alt"><span>} </span></li>
</ol>

Of course, you can do it with the PHP configuration function ini_get() There are many uses, you can slowly experience them yourself.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446227.htmlTechArticleOutput: display_errors = 1 register_globals = 0 post_max_size = 8M post_max_size+ 1 = 9 PHP configuration function ini_get() is mainly for Obtaining the configuration file can facilitate many operations for you. Than...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn