note 69898 deleted from function.ini-get by nlopess

From: Date: Sat, 29 Dec 2007 11:41:01 +0000
Subject: note 69898 deleted from function.ini-get by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134104@lists.php.net to get a copy of this message
Note Submitter: petrov dot michael at gmail dot com ---- @Webmaster at GrimChild dot com Your suggestion to simply strip the [gmk] letters would actually be very unpredictable since you no longer know the magnitude of the number. Therefore if you have 8K and 8M they would be both equal after your function. Also the following would be incorrect: <?php // Incorrect code function parse_size($size) { return eregi_replace('[gmk]','',$size); } //Check that we have at least 4M of post space // assume post_max_size = 16K if(parse_size(ini_get('post_max_size')) < parse_size("4M")) { die('Error: this script requires more than 4M of post space'); } ?> As you can see in this scenario the functions would return 16 and 4 respectively, allowing the check to succeed with less memory than 4M.

« previous php.notes (#134104) next »