# Getting integer value for ini entries that support shorthanded sizing.

- Thread: https://externals.io/message/53014
- Original archive: https://news-web.php.net/php.internals/53014
- Started by Richard Quadling on 2011-06-06T11:47:59+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #53014 — Richard Quadling — 2011-06-06T11:47:59+00:00

URL: https://externals.io/message/53014#53014

Hi.

Is there a mechanism to get the memory_limit value rather than the
string when it is set with the K, M or G shorthands.

I can see that ...

PHP_INI_ENTRY("memory_limit", "128M", PHP_INI_ALL, OnChangeMemoryLimit)
...
static PHP_INI_MH(OnChangeMemoryLimit)
{
	if (new_value) {
		PG(memory_limit) = zend_atol(new_value, new_value_length);
	} else {
		PG(memory_limit) = 1<<30;		/* effectively, no limit */
	}
	return zend_set_memory_limit(PG(memory_limit));
}


calls zend_atol - which does the translation.

The value is applied to the PHP Global structure, but the value
retrieved and stored in the ini_entries array from the ini file (the
string "1G" for example) is not overwritten.

Would it be worthwhile amending the INI macros so that zend_atol and
zend_atoi (and others if appropriate) where called earlier in the
sequence of events.

That way, ini_get('memory_limit') would return the memory limit in
bytes, rather than the shorthand.

Richard

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
