Non-decimal radices/Input: Difference between revisions

added php
(added php)
Line 98:
 
=={{header|Perl}}==
The <tt>hex()</tt> function parses hexadecimal strings. The <tt>oct()</tt> function parses octal strings, as well as hexadecimal, octal, or binary strings with the appropriate prefix ("0x", "0", and "0b", respectively). There is no need to parse decimal strings because in Perl decimal strings and numbers are interchangeable.
<lang perl>my $dec = "0123459";
my $hex_noprefix = "abcf123";
Line 115:
# nothing for binary without prefix
</lang>
 
=={{header|PHP}}==
The <tt>hexdec(), octdec(), bindec()</tt> function parses hexadecimal, octal, and binary strings, respectively. They skip any invalid characters, so a prefix will be ignored. There is no need to parse decimal strings because in Perl decimal strings and numbers are interchangeable.
<lang php><?php
echo 0 + "0123459"; // prints 123459
echo hexdec("abcf123"); // prints 180154659
echo octdec("7651"); // prints 4009
echo bindec("101011001"); // prints 345
?></lang>
 
=={{header|Python}}==
Anonymous user