note 103308 deleted from function.ini-get by danbrown
| From: | danbrown@php.net | Date: | Wed, 06 Apr 2011 15:57:55 +0000 |
| Subject: | note 103308 deleted from function.ini-get by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178567@lists.php.net to get a copy of this message | ||
Note Submitter: php at ianco couk
----
Following on from Stas Trefilov's example, here's an inline version (no function). In this
example, we set memory_limit to 64M unless it is already more than that.
<?php
switch(substr($va = ini_get('memory_limit'), -1)) {
case 'M' : case 'm' : $va = (int) $va * 1048576; break;
case 'K' : case 'k' : $va = (int) $va * 1024; break;
case 'G' : case 'g' : $va = (int) $va * 1073741824; break;
default : $va = 0; break;
}
if ($va < 64 * 1048576) ini_set('memory_limit', '64M');
?>