Introduction to PHP printing binary form
- $row[permission]=u;// or =chr(117)
-
- echo "
id = " . str_pad(decbin(ord(ord($row[permission])),8,0,STR_PAD_LEFT);
- echo " < ;br /> id = ";
- printf("%08b
",ord($row[permission]));
- ?>
- Output:
- id = 01110101
- id = 1110101
-
printf explanation:
%: % Bit symbol
0: Fill the unfull width with 0
8: 8 bits in total
b: Binary mode
http://www.bkjia.com/PHPjc/486139.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486139.htmlTechArticleIntroduction to PHP printing binary form?php $row[permission]=u;// or =chr(117) echo " br / id = " . str_pad(decbin(ord($row[permission])),8,0,STR_PAD_LEFT); echo " br / id = "; printf("%08...