checking memory_limit in PHP

后端 未结 9 1562
臣服心动
臣服心动 2020-12-29 01:40

I\'m need to check if memory_limit is at least 64M in my script installer. This is just part of PHP code that should work, but probably due to this

9条回答
  •  忘掉有多难
    2020-12-29 02:21

    Thank you for inspiration.

    I had the same problem and instead of just copy-pasting some function from the Internet, I wrote an open source tool for it. Feel free to use it or provide feedback!

    https://github.com/BrandEmbassy/php-memory

    Just install it using Composer and then you get the current PHP memory limit like this:

    $configuration = new \BrandEmbassy\Memory\MemoryConfiguration();
    $limitProvider = new \BrandEmbassy\Memory\MemoryLimitProvider($configuration);
    $limitInBytes = $memoryLimitProvider->getLimitInBytes();
    

提交回复
热议问题