This paper is reproduced from http://blog.csdn.net/littlebo01/article/details/45199161
Note that this is the world of PHP, please note the prerequisites, you say this is not important, what you say this is nonsense. Penalty you read the PHP online handbook for 3 days ...
Impression in the script to modify the configuration, conveniently picked:
@ Code One
Ini_set (' Memory_limit ', ' 1024M ');
Remember it's best to put it in front of the file, so
@ Code Two
echo ini_get (' Memory_limit ');
Ini_set (' Memory_limit ', ' 1024M ');
echo ini_get (' Memory_limit ');
Exit
The result is 128M; there is no authority. is not placed at the front of the file. Can't be modified.
Test code one can modify ...
Dry goods come in 1:
Read the manual:
Modifiable range is php_ini_perdir, you may not know what this means (reference: http://blog.csdn.NET/bravezhe/article/details/18351975)
PHP has a total of 4 configuration Directives scope: (Each instruction in PHP has its own scope, the instruction can only be modified in its scope, not anywhere can modify the configuration instructions)
Php_ini_perdir: Instructions can be modified in php.ini, httpd.conf, or. htaccess files
Php_ini_system: Directives can be modified in php.ini and httpd.conf files
Php_ini_user: Directives can be modified in user scripts
Php_ini_all: Instructions can be changed anywhere
Dry Goods come in 2:
Safe mode is turned on: code one is also invalid.
The test found Ini_set (' Safe_mode ', true) on PHP version = ' 5.3.3 ';
needs to be modified under php.ini:
Dry Goods come in 3:
How to modify code two:
Add directly to the. htaccess file
Php_value upload_max_filesize "3M"
Friends of the machine can, their own invalid, to be studied.
or modify the httpd.conf file, specifically how to modify the study.
Test Cases:
<?php//Test Ini_set () error_reporting (e_all ^ e_notice);
Date_default_timezone_set ("PRC"); Echo ' Start ...: '. Date (' y-m-d h:i:s '). "
\ n ";
Echo ' safe_mode= '; Var_dump (Ini_get (' Safe_mode '));
if (!ini_get (' Safe_mode ')) {echo is not safe mode \ n]; echo "Default memory_limit=". Ini_get (' Memory_limit '). "
\ n ";
Ini_set (' Memory_limit ', ' 1023M '); echo "Modified memory_limit=". Ini_get (' Memory_limit '). "
\ n ";
echo "\n****************************\n"; echo "Default Upload_max_filesize=". Ini_get (' upload_max_filesize '). "
\ n ";
Ini_set (' upload_max_filesize ', ' 8M '); echo "Modified upload_max_filesize=". Ini_get (' upload_max_filesize '). "
\ n "; echo "\ n". ' End ...: '. Date (' y-m-d h:i:s '). "
\ n ";
else {echo ' safe mode \ n '; echo "Default memory_limit=". Ini_get (' Memory_limit '). "
\ n ";
Ini_set (' Memory_limit ', ' 1023M '); echo "Modified memory_limit=". Ini_get (' Memory_limit '). "
\ n ";
echo ' End '; echo "Default Upload_max_filesize=". Ini_get (' upload_max_filesize '). " \n ";
Ini_set (' upload_max_filesize ', ' 8M '); echo "Modified upload_max_filesize=". Ini_get (' upload_max_filesize '). "
\ n ";
echo ' End '; }?>