The octdec()
method can be used to convert an octal string to a decimal number.
octdec(string $octal_string): int|float
octal_string
argument are skipped.From PHP 7.4.0, any invalid characters in
octal_string
are deprecated.
octal_string
argument should be a type of string, otherwise unexpected results will be produced.octdec
returns the decimal number of type int
or float
, based on the size of the value.
<?php$num = "70";echo "decimal value of ". $num. " is: ". octdec($num)."\n";$num = "77";echo "decimal value of ". $num. " is: ". octdec($num)."\n";$num = "100";echo "decimal value of ". $num. " is: ". octdec($num)."\n";$num = "107";echo "decimal value of ". $num. " is: ". octdec($num)."\n";?>
In the code above, we use the octdec
method to convert the octal strings of 70
, 77
, 100
and 107
into decimal representation.