使用 PHP 图像缓存缓存带有源 URL 的图像

Caching images with URLs fopr sources using PHP Image Cache

我正在使用 OMDB API (http://omdbapi.com/) to get movie images. I want to cache these so I can load them from my server. I am using PHP Image Cache (http://nielse63.github.io/php-image-cache/)。但是我收到以下错误:

Allowed memory size of 262144 bytes exhausted (tried to allocate 106496 bytes)

我已将我的 PHP 文件中的 memory_limit 设置为 256,并且在脚本运行之前尝试了 ini_set('memory_limit','1024M');,但我仍然遇到相同的错误。 262144 的允许内存大小永远不会改变。

我该如何解决这个问题?

解决方案

我最终在这里找到了答案:Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

我不太明白的是为什么要修复它?将 memory_limit = 256mb 更改为 268435456 但它已经成功了。

What I don't really understand is why this fixed it? Changing memory_limit = 256mb to 268435456 but it has done the trick.

发生这种情况是因为 PHP 无法理解您的语法。您必须正确提供大小为“256M”或“1G”。你也可以做一个像 ini_set('memory_limit',256*1024); 这样的技巧。但默认测量单位将由 php 设置

生成