PHP bindec()函数

PHP bindec()函数

PHP bindec()函数是一个数学函数,用于将二进制数转换为十进制数。它返回二进制字符串的十进制值。

注意:要通过使用decbin()函数将十进制数转换为二进制数。

语法

bindec(binary_string);
参数 描述 必需/可选
binary_string 指定要转换的二进制字符串,参数值必须是字符串。 必需

示例1

<?php
binary='110011';
echo "Your binary number is : ".binary;
echo "<br>"."By using ?bindec()' function your decimal number is :".bindec($binary);
?>

输出:

Your binary number is : 110011
By using bindec()' function your decimal number is :51

示例2

<?php
binary='01';
echo "Your binary number is : ".binary;
echo "<br>"."By using 'bindec()' function your decimal number is :".bindec($binary);
?> 

输出:

Your binary number is : 01
By using 'bindec()' function your decimal number is :1

示例3

<?php
binary='000110011';
echo "Your binary number is : ".binary;
echo "<br>"."By using 'bindec()' function your decimal number is :".bindec($binary);
?>

输出:

Your binary number is : 000110011
By using 'bindec()' function your decimal number is :51

示例4

<?php
binary='1010';
echo "Your binary number is : ".binary."<br>";
echo var_dump(bindec($binary));
?>

输出:

Your binary number is : 1010
int(10)

示例5

<?php
binary='10000';
echo "Your binary number is : ".binary."<br>"; 
echo "By using 'bindec()' function your decimal number is :".bindec($binary);
?>

输出:

Your binary number is : 10000
By using 'bindec()' function your decimal number is :16

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程