Home  >  Article  >  php教程  >  PHP中ini_set和ini_get函数的用法小结

PHP中ini_set和ini_get函数的用法小结

WBOY
WBOYOriginal
2016-06-13 09:30:301377browse

php中的ini_set函数是php自带的用来修改设置php.ini配置文件的函数,用这个函数很方便,不用去手动修改php.ini文件,有时候我们也没有权限去修改php.ini文件,这时就用这个函数。

语法:ini_set("选项","值");该函数用时最好放到php的脚本最头部

比如:ini_set("max_execution_time", "180");//设置php的脚本超时时间为180秒

具体php选项可参考phpinfo文件的 Configuration PHP Core 部分

ini_get正好和ini_set相反,用来取php.ini文件里的环境变量的值.

语法:string ini_get (string varname );返回选项的值,如果选项的值为布尔型则返回为0或1

比如:echo ini_get('max_execution_time');//输出 30

如果想获取整个php.ini里的变量值,我们可以用ini_get的加强函数 ini_get_all()它以数组的形式返回整个php的环境变量。

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