Backend Development 2 min read
PHP octdec Function: Converting Octal Strings to Decimal Numbers
This article explains PHP's octdec function, detailing its syntax, parameters, return value, and providing example code that demonstrates how to convert an octal string to its decimal equivalent and display the result.
Laravel Tech Community
Laravel Tech Community
The octdec function in PHP converts a string representing an octal number into its decimal equivalent.
Syntax :
number octdec(string $octal_string)Parameter :
$octal_string – The octal number expressed as a string that you want to convert.
Return value :
The function returns the decimal representation of the provided octal string.
Example :
<?php
echo octdec('77') . "\n"; // converts octal 77 to decimal
echo octdec(decoct(45)); // converts decimal 45 to octal then back to decimal
?>Output :
63
45Written by
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
0 followers
Reader feedback
How this landed with the community
Rate this article
Was this worth your time?
Discussion
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.