Menu Home

octdec

osbo.com | PHP | Functions | octdec

Octal to decimal

Syntax

octdec ( string $octal_string ) : number

Parameters

octal_string

The octal string to convert. Any invalid characters in octal_string are silently ignored.

Octal Decimal
0 0
1 1
2 2
... ...
777777777777777777776 9223372036854775806
777777777777777777777 9223372036854775807 (largest signed integer)
1000000000000000000000 9223372036854775808
... ...
1777777777777777777776 18446744073709551614
1777777777777777777777 18446744073709551615 (largest unsigned integer)

Return

The decimal representation of octal_string

Examples

1

<?

$octal_string1 = "0";
$octal_string2 = "089abcdefghijklmnopqrstuvwxyz";

$return1 = octdec($octal_string1);
$return2 = octdec($octal_string2);

echo $return1 . PHP_EOL;
echo $return2;

?>
0
0

2

<?

$octal_string = "1";

$return = octdec($octal_string);

echo $return;

?>
1

3

<?

$octal_string = "2";

$return = octdec($octal_string);

echo $return;

?>
2

4

<?

$octal_string = "777777777777777777776";

$return = octdec($octal_string);

echo $return;

?>
9223372036854775806

5

<?

$octal_string = "777777777777777777777";

$return = octdec($octal_string);

echo $return;

?>
9223372036854775807

6

<?

ini_set("precision", 19);

$octal_string = "1000000000000000000000";

$return = octdec($octal_string);

echo $return;

?>
9223372036854775808

7

<?

ini_set("precision", 20);

$octal_string = "1777777777777777777776";

$return = octdec($octal_string);

echo $return;

?>
18446744073709551616

8

<?

ini_set("precision", 20);

$octal_string = "1777777777777777777777";

$return = octdec($octal_string);

echo $return;

?>
18446744073709551616

PHP