1. Home
  2. Computing & Technology
  3. PHP / MySQL

Is_Binary () PHP Function

By Angela Bradley, About.com

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."

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Is_binary PHP Function - Checks if a number is Binary

©2008 About.com, a part of The New York Times Company.

All rights reserved.