Req #64530 [Opn]: Missing function to translate shorthand notation to bytes
Edit report at https://bugs.php.net/bug.php?id=64530&edit=1
ID: 64530
Updated by: cmb@php.net
Reported by: contact at jfsimon dot fr
Summary: Missing function to translate shorthand notation to
bytes
Status: Open
Type: Feature/Change Request
Package: *General Issues
PHP Version: 5.3.23
Block user comment: N
Private report: N
New Comment:
Admittedly, it's not trivial to port zend_atol()[1] to userland;
you can get mostly away with using intval($foo, 0) and switching
on the last character, but that doesn't cater to stuff like
128 (hey cool, I can leave a comment here!) M
what is "perfectly" valid, and is parsed like 128M. In my
opinion, this is a bug, but one that we can't easily fix for BC
reasons.
To cater to that you actually need regexps, so this feature
request makes some sense.
[1] <https://github.com/php/php-src/blob/php-7.4.23/Zend/zend_operators.c#L109-L134>
Previous Comments:
------------------------------------------------------------------------
[2013-03-27 08:59:08] victor at suumit dot com
'ini_translate_shortand($shorthand)' should translate a shorthand notation to its
integer counterpart.
This is useful as the process is not as simple as described in the doc @
http://www.php.net/manual/en/function.ini-get.php
- the doc needs either to be
fixed or at least a warning should be added as not all formats are supported by
the given conversion method.
The method described in the doc is wrong as octal and hexadecimal values are
supported in the shorthand notation (008, 0x10M, ...)
------------------------------------------------------------------------
[2013-03-27 08:46:00] contact at jfsimon dot fr
This took me 4 days and 3 PRs to correctly add this method in Symfony.
https://github.com/symfony/symfony/pull/7456
https://github.com/symfony/symfony/pull/7481
https://github.com/symfony/symfony/pull/7489
------------------------------------------------------------------------
[2013-03-27 08:42:31] contact at jfsimon dot fr
Description:
------------
It would be really nice to add a 'ini_translate_shortand($shortand)' function as
this is a real pain to exactly know how to do it.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64530&edit=1
Thread (4 messages)