You are here: Re: Using octal number from user input « PHP « IT news, forums, messages
Re: Using octal number from user input

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация