1. Computing

Discuss in my forum

Is_Binary () PHP Function

By , About.com Guide

Definition: The Is_Binary () PHP function is used to check if a number is binary. Binary numbers are also called base two. This function will return true or false. If you need a number to be binary and it is not, you can use the base_convert () function to make it binary.
Also Known As: Is Binary, Binary check
Examples:
 <?php 
 if (is_binary (1001)) 
 {
 echo "Yes";
 } else {
 echo "No";
 }
 ?>
 
Since 1001 is the binary version of 9, this will echo "Yes."

 <?php 
 if (is_binary (1201)) 
 {
 echo "Yes";
 } else {
 echo "No";
 }
 ?> 
Since 1201 is not binary, this will echo "No."
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. PHP Functions
  5. Is_binary PHP Function - Checks if a number is Binary

©2013 About.com. All rights reserved.