• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PHP bindec function – Convert a number between arbitrary bases

by admin

Description

The bindec() function converts a binary number into a decimal number. It takes just one parameter, which is the number to convert. For example:

print decbin("10000"); // 16

Syntax:

bindec(string $binary_string): int|float

Up to a 32-bit number, or 2,147,483,647 decimal, can be converted.

Parameters

Parameter Description
binary_string The binary string to convert. Any invalid characters in binary_string are silently ignored

Return Values

Decimal integer form of a binary number

Examples

Example 1: Convert a binary number to decimal:

$number = "101010"; 
echo "Binary $number is ", bindec($number), "in decimal"; 

Filed Under: PHP

Some more articles you might also be interested in …

  1. PHP Function str_word_count() – Return information about words used in a string
  2. PHP function strcasecmp() – Binary safe case-insensitive string comparison
  3. PHP function convert_cyr_string() – Convert from one Cyrillic character set to another
  4. PHP cos function – Cosine
  5. htaccess Cheatsheet
  6. PHP Function strchr() – Alias of strstr()
  7. “Access denied for user ‘username’@’hostname’ (using password: YES)” – Error while connecting MySQL with PHP
  8. PHP function abs – Absolute value
  9. How to test a PHP script
  10. PHP addslashes function – Quote string with slashes

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright