Home  >  Article  >  Backend Development  >  How to convert php string to octal number

How to convert php string to octal number

藏色散人
藏色散人Original
2021-06-26 09:27:572103browse

In PHP, you can convert decimal to octal through the decoct function. The syntax is such as "decoct(int $number);". The parameter "$number" represents the decimal number to be converted and the maximum value that can be converted. It is 4294967295 in decimal.

How to convert php string to octal number

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php How to convert a string to an octal number?

Decimal to octal:

Function:decoct(int $number);

@param $number to be converted For decimal numbers, the maximum value that can be converted is 4294967295 in decimal, and the decoct() result is "37777777777".

                    @return   Returns a string containing the octal representation of the given $number argument.

Function Description:

The maximum decimal value that the decoct() function can convert is 4294967295, and the result is "37777777777".

Example:

<?php
    echo  decoct ( 10 ) . "\n" ;
    echo  decoct ( 50 );

The above program statements will be output in sequence: 12, 62

Recommended learning: "PHP Video Tutorial

The above is the detailed content of How to convert php string to octal number. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn