2017-04-21 42 views
0

時候我已經嘗試設置php.ini中的限制,但我總是得到同樣的錯誤設置PHP CLI memory_limit的:我如何使用XAMPP

用盡262144個字節

允許的內存大小(試圖分配341351個字節)通過調用php -d memory_limit=2048M的script.php在線0

我可以解決這個未知

但無法弄清楚如何處理作曲家做。

+1

PHP有時會針對CLI與Web服務器使用不同的php.ini文件。使用'php -i'找出它在CLI上加載的php.ini文件,並在那裏設置'memory_limit'。正在使用的ini應該接近輸出的開始。 –

+0

另請參閱http://stackoverflow.com/questions/1751719/php-command-line-scripts-are-ignoring-php-ini-and-ini-setmemory-limit-di –

回答

0

最頂部添加此您的PHP腳本中的PHP ini_set("memory_limit", "2048M");的代碼。請務必根據您的需要增加memory_limit

如果您不斷收到此類錯誤消息exhausted memory。你可以使用ini_set("memory_limit", "-1");。這會將您的內存限制設置爲無限制。

Note: This will set your memory limit to no limit. Memory limit is the thing which is dependent on your OS and RAM not on PHP .

Note: Also please make sure if you are doing something on your production environment in your PHP script, whose job is to keep on adding data to there script, either in your static variables(Example:gathering multiple CSV's data) or some arrays, then it can lead to either failure of that VM or PHP process in case of complete memory exhaust.

0

的CLI中XAMPP默認的php.ini文件位於%xamppRoot%\ PHP \ php.ini中不低於%xamppRoot%\ apache的\斌\ php.ini中