php ini_set函数无效怎么解决_PHP教程

WBOY
Freigeben: 2016-07-13 10:56:25
Original
1112 Leute haben es durchsucht

利用ini_set可以快速的修改php.ini配置设置哦,无需打开php.ini就可以了,特别是虚拟主机时你没有修改php.ini的权限时就会发现这个函数的作用了,关于ini_set,post_max_size,upload_max_filesize,magic_quotes_gpc等用ini_set设置不了的解决办法!

 代码如下 复制代码

ini_set(‘max_execution_time’,’10′);
ini_set(‘memory_limit’,’1024M’);

echo ‘max_execution_time = ‘ . ini_get(‘max_execution_time’) . ”
“;
echo ‘memory_limit = ‘ . ini_get(‘memory_limit’) . ”
“;
echo ‘post_max_size = ‘ . ini_get(‘post_max_size’) . ”
“;
echo ‘upload_max_filesize = ‘ . ini_get(‘upload_max_filesize’) . ”
“;

ini_set(‘max_execution_time’,’10′);
ini_set(‘memory_limit’,’1024M’);

注意:

post_max_size,upload_max_filesize用下面的方法是修改不了的.
ini_set(‘post_max_size’,’1024M’);
ini_set(‘upload_max_filesize’,’1024M’);

正确做法是用.htaccess文件:

 代码如下 复制代码

php_value upload_max_filesize “80M”
php_value post_max_size “80M”
php_value max_execution_time “2000″
php_value memory_limit “150M”

实例设置max_execution_time

 代码如下 复制代码


 $old_max_execution_time = ini_set('max_execution_time', 120);
   echo "old timeout is $old_max_execution_time
";

   $max_execution_time = ini_get('max_execution_time');
   echo "new timeout is $max_execution_time
";
  
  
  
  echo 'function sets supported in this install are:
';
  $extensions = get_loaded_extensions();
  foreach ($extensions as $each_ext)
  {
    echo "$each_ext
";
    echo '

    ';
        $ext_funcs = get_extension_funcs($each_ext);
        foreach($ext_funcs as $func)
        {
           echo "
  • $func
  • ";
        }
        echo '
';
  }
?>

补充知识点:

其实在php文档里有说明upload_max_filesize的可修改范围是PHP_INI_PERDIR。
PHP_INI_PERDIR的意思是域内指令可以在php.ini、httpd.conf或.htaccess文件中修改。
PHP_INI_SYSTEM 域内指令可以在php.ini和httpd.conf文件中修改
所以upload_max_filesize用int_set是无法修改的。只有可修改范围是PHP_INI_ALL的才可以用int_set修改。

magic_quotes_gpc 用 get_magic_quotes_gpc() 获得,不能用 set_magic_quotes_gpc 修改,原因是没这个函数。而magic_quotes_runtime可以用set_magic_quotes_runtime()来设置

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632163.htmlTechArticle利用ini_set可以快速的修改php.ini配置设置哦,无需打开php.ini就可以了,特别是虚拟主机时你没有修改php.ini的权限时就会发现这个函数的作用...
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!