How to display binary integer value in PHP

How to echo a binary integer value in PHP? I tried using pack('S',$var) but didn't show any results ...

+4
source share
2 answers
 decbin($number); 

Returns a string containing the binary representation of the argument of the given number.

For example, decbin(26) will return 11010

Source documents for decbin ()

+8
source
 <?php echo base_convert($number, 10, 2); ?> 

http://php.net/manual/en/function.base-convert.php

string base_convert ( string $number , int $frombase , int $tobase )

+5
source

Source: https://habr.com/ru/post/1412754/


All Articles