How to convert decimal to binary in php

WBOY
Release: 2023-03-15 13:16:01
Original
2773 people have browsed it

In PHP, you can use the decbin() function to convert a decimal number into a binary number. The return result of this function is a binary number containing a decimal value. The syntax is "decbin(number);".

How to convert decimal to binary in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to convert decimal to binary in php

The decbin() function converts decimal numbers into binary numbers.

To convert binary to decimal, please see bindec() function

Syntax

decbin(number);
Copy after login

Parameter Description

number Required. Specifies the decimal value to be converted.

Return value: A string containing a binary number with a decimal value.

Examples are as follows:

<?php
echo decbin("3") . "<br>";
echo decbin("1") . "<br>";
echo decbin("1587") . "<br>";
echo decbin("7");
?>
Copy after login

Output results:

How to convert decimal to binary in php

## Recommended learning: "

PHP Video Tutorial

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template