php通过ini_set修改php.ini配置例子

<?php  
      //读取php.ini的初使值  
      echo ini_get('file_uploads')."<br>";  
      echo ini_get('max_input_time')."<br>";  
      echo ini_get('max_execution_time')."<br>";  
      echo ini_get('post_max_size')."<br>";  
      echo ini_get('upload_max_filesize')."<br>";  
      echo ini_get('memory_limit')."<br>";  
    
      //修开php.ini配置  
      ini_set('file_uploads','ON');//Http上传文件的开关,默认为开  
      ini_set('max_input_time','90');//通过post,以及put接收数据时间,默认为60秒  
      ini_set('max_execution_time','180');//默认为30秒,脚本执行时间修改为180秒  
      ini_set('post_max_size','10M');//修改post变量由2m变成1om,要比upload_max_filesize大  
      ini_set('upload_max_filesize','8M');//文件上传最大  
      ini_set('memory_limit','90M');//内存使用问题,最好比post_max_size大1.5倍  
   
      //修改后的数据  
      echo "<hr>";  
      echo ini_get('file_uploads')."<br>";  
      echo ini_get('max_input_time')."<br>";  
      echo ini_get('max_execution_time')."<br>";  
      echo ini_get('post_max_size')."<br>";  
      echo ini_get('upload_max_filesize')."<br>";  
      echo ini_get('memory_limit')."<br>";  
  ?>

但在安全模式下不能使用ini_set的指令:max_input_time、post_max_size、upload_max_filesize

此时的做法通.htaccess进行配置,但前提要求设置是 AllowOverride All

  1. php_value upload_max_filesize 8M   

  2. php_value post_max_size 10M   


你可能感兴趣的:(php通过ini_set修改php.ini配置例子)