note 50965 deleted from function.eval by sniper

From: Date: Thu, 29 Dec 2005 09:15:13 +0000
Subject: note 50965 deleted from function.eval by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100906@lists.php.net to get a copy of this message
Note Submitter: relic at daimi dot au dot dk ---- A small heads up regarding numbers and forms: If you do <?php eval('\$foo = 023;'); ?> The value of $foo will be 19, because 023 is evaluated as an octal number. Why is this interesting? It created an odd problem for me because I had a form field taking a number from the user. This number was part of an eval. The field had a default 0 in it and the user would just put 23 behind that without deleting the 0 first, expecting it (understandably) to have the value 23. Note also that if you do <?php $bar = (integer) "023"; $foobar = (integer) 023; ?> The value of $bar will be 23, as expected, while the value of $foobar will be 19. It is quite consistent but imagine my confusion... In light of this the solution in my case was to do <?php eval('\$foo = (integer) "023";'); ?>

« previous php.notes (#100906) next »