Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert decimal to Octal in php

Shulou Source: shulou.com Published: 2022-06-02 11:37:52 10月01日 Update

This article is about how to convert decimal to octal in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Php to achieve decimal to octal methods: 1, create a PHP sample file; 2, through the "decoct ()" method to convert decimal values to octal.

This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.

The code is as follows:

/ / decimal, binary, octal, hexadecimal conversion / / decimal to binary decbin () function: / / echo decbin (5); / / output: 101max / decimal to octal decoct () function / / echo decoct (15); / / 17//echo decoct (999); / / 1747pm / decimal to hexadecimal dechex () function / echo dechex (10); / / output: a / / binary (binary system) conversion function / / 1. Binary to hexadecimal bin2hex () function / / $binary = "11111001"; / / $hex = dechex (bindec ($binary)); / / convert binary to decimal first, then decimal to hexadecimal. / / echo $hex;// output f9 / / 2. Convert binary to decimal: bindec function / / echo bindec ('110011'); / output 51amp / convert octal to decimal function: / / echo octdec ('77'); / / output: 63pm / hexadecimal to decimal / / var_dump (hexdec (' See')); / / output: int 238mp / arbitrary conversion: base_convert () / hexadecimal to binary / / $num='Ae' / / echo base_convert ($num,16,2); / / output: 10101110

Thank you for reading! This is the end of the article on "how to convert php from decimal to octal". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Decimal decimal binary function output hexadecimal octal content method more article good practical code numeric file article environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft Shulou Tech Info MariaDB macOS