octdec()

octdec() — Octal to decimal.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns the decimal equivalent of the octal number represented by the octal_string argument.

Signature

octdec(string $octal_string): int|float

Parameters

ParameterTypeWhat it takes
$octal_stringstringThe octal string to convert. Any invalid characters in octal_string are silently ignored. As of PHP 7.4.0 supplying any invalid characters is deprecated.

Return value

The decimal representation of octal_string

Example

A runnable snippet:

echo octdec('77') . "\n"; echo octdec(decoct(45));

Output:

63 45

Changelog

VersionChange
7.4.0Passing invalid characters will now generate a deprecation notice. The result will still be computed as if the invalid characters did not exist.

See also

decoct(), bindec(), hexdec(), base_convert()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page octdec() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.