Heim  >  Artikel  >  Backend-Entwicklung  >  PHP修改memory_limit内存限制的方法详解_PHP教程

PHP修改memory_limit内存限制的方法详解_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:00:211103Durchsuche

今天我的新一台服务器安装了php环境但在在运行时提示Fatal Error: Allowed memory size of xxxxxx bytes exhausted了,是内存不足呀,下面我来介绍解决些问题的几种办法。

解决办法

方法1:编辑php.ini 在php.ini中

找到“memory_limit”这一项,如果没有,你可以在文件的尾部自己增加这个参数。以下是一些设置范例

memory_limit = 128M ; 可以将128M改为任何你想设置的值


方法2: .htaccess

说明: 这种方法只有在php以Apache模块来执行时才生效。 在你的网站的根目录下找到“.htaccess”文件,如果没有,可以自己创建一个。然后把以下配置放入其中

php_value memory_limit 128M ; 可以将128M改为任何你想设置的值

方法3: 运行时修改php的内存设置

在你的php代码中增加以下命令行即可。

ini_set('memory_limit','128M');

友情提示

如果你是php5.2.17可能上面办法对你都无效哦,这个官方就是bug无法解决些问题,我们也只能重新安装php环境了,如php5.4

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631258.htmlTechArticle今天我的新一台服务器安装了php环境但在在运行时提示Fatal Error: Allowed memory size of xxxxxx bytes exhausted了,是内存不足呀,下面我来介绍解决...
Stellungnahme:
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