Comments on: How to test PHPs memory_limit setting https://blog.plip.com/2015/08/04/how-to-test-phps-memory_limit-setting/ Sat, 08 Aug 2015 04:54:30 +0000 hourly 1 https://wordpress.org/?v=6.7.1 By: mrjones https://blog.plip.com/2015/08/04/how-to-test-phps-memory_limit-setting/#comment-5108 Sat, 08 Aug 2015 04:54:30 +0000 http://blog.plip.com/?p=1321#comment-5108 In reply to Firebus.

Totally cool. I love the deep dive! Bonus points for the gist ;)

]]>
By: Firebus https://blog.plip.com/2015/08/04/how-to-test-phps-memory_limit-setting/#comment-5107 Sat, 08 Aug 2015 03:52:09 +0000 http://blog.plip.com/?p=1321#comment-5107 In reply to mrjones.

Oh yah, derp, because you can use shorthand notation like ‘128M’ and that’s what gets returned literally by ini_get(). No conversion is done for you.

I initially misremebered there being a built-in to convert, but I must have been remembering the discussion here: http://php.net/manual/en/function.ini-get.php#refsect1-function.ini-get-examples

So, easy enough to use ini_get(‘memory_limit’) but not as easy to one-liner. Also memory_limit has a special value of -1 for unlimited that should be handled (in that case you’d want to get the total memory installed on the server and pad a string that far? :)

This would be better as a little module: https://gist.github.com/firebus/2e324b1261f0e2cbe1f9

I’m afraid to run it with memory_limit set to -1…

]]>
By: mrjones https://blog.plip.com/2015/08/04/how-to-test-phps-memory_limit-setting/#comment-5100 Fri, 07 Aug 2015 21:23:00 +0000 http://blog.plip.com/?p=1321#comment-5100 In reply to Firebus.

Oh, awesome! Assign a variable that is the size of memory_limit and it will inherently exceed that size. Neat!

However, When I run it in a full LAMP stack, I get an error:

PHP Error 8:

Message:
A non well formed numeric value encountered
in /vagrant/application/views/_layout/header.php:1

]]>
By: Firebus https://blog.plip.com/2015/08/04/how-to-test-phps-memory_limit-setting/#comment-5067 Thu, 06 Aug 2015 06:11:49 +0000 http://blog.plip.com/?p=1321#comment-5067 $foo = str_pad(”, ini_get(‘memory_limit’));

]]>