Home > php教程 > php手册 > 如何正确运用PHP ini_set函数

如何正确运用PHP ini_set函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:08:26
Original
848 people have browsed it

在PHP配置函数中,有一种函数的功能是实现设置php.ini中的某些变量值的。它就是我们今天要为大家介绍的PHP ini_set函数。

  • ini_set函数是设置选项中的值,在执行函数后生效,脚本结束的时候,这个设置也失效。不是所有的选项都能被改函数设置的。具体那些值能够设置,可以查看手册中的列表。

    就是能够设置php.ini中的选项值比如,display_error选项关闭了,但是你要显示程序中的错误信息,方便你调试程序,那么就可以使用PHP ini_set函数:

    <ol class="dp-xml"><li class="alt"><span><span>ini_set(”display_errors<br>”, “On”); </span></span></li></ol>
    Copy after login

    那么在你这个页面的程序都会显示错误信息了,而且你还可以使用error_reporting来设置显示的错误信息级别。
    如果你需要增加脚本执行时间,那么可以设置:

    <ol class="dp-xml"><li class="alt"><span><span>ini_set(”max_execution<br>_time”, “180″); </span></span></li></ol>
    Copy after login

    那么脚本执行时间就由默认的30秒变为180秒,当然,你也可以使用set_time_limit()来设置。

    其实你把PHP ini_set函数和ini_get结合使的话,非常好。比如你想在配置文件里添加自己的包含文件路径,但是你有没有权限更改php.ini,那么你可以结合两个函数:

    <ol class="dp-xml"><li class="alt"><span><span>ini_set(’include_path’<br>,ini_get(’include_path’).<br>’:/your_include_dir:’);  </span></span></li></ol>
    Copy after login


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template