|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64530 Missing function to translate shorthand notation to bytes
Submitted: 2013-03-27 08:42 UTC Modified: 2021-08-26 14:14 UTC
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: contact at jfsimon dot fr Assigned:
Status: Open Package: *General Issues
PHP Version: 5.3.23 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: contact at jfsimon dot fr
New email:
PHP Version: OS:


 [2013-03-27 08:42 UTC] contact at jfsimon dot fr
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-27 08:46 UTC] contact at jfsimon dot fr
This took me 4 days and 3 PRs to correctly add this method in Symfony.
 [2013-03-27 08:59 UTC] 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 @ - 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, ...)
 [2021-08-26 14:14 UTC]
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

To cater to that you actually need regexps, so this feature
request makes some sense.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 16:01:33 2024 UTC