Posted by Bernhard Kraft on 10/21/42 11:06
Bob wrote:
> :User enters 040 in field uinput on form
> :
> :print $_POST['uinput'] * 2;
PHP does not automatically recognize the base in which numbers are
given ...
when it does string-2-integer conversion as it takes place in your example:
$_POST['uinput'] * 2
($_POST['uinput'] gets converted to a number) it will always asume your
number to be in base-10
you can do base conversions using:
string base_convert ( string number, int frombase, int tobase)
http://at2.php.net/manual/en/function.base-convert.php
but you will have to check with your code if the number is in
octal (preceeding 0) or in hexadecimal (preceeding 0x) or other
bases ...
greets,
Bernhard
Navigation:
[Reply to this message]
|