Home > php教程 > php手册 > php 通过二进制数来存取开关数据

php 通过二进制数来存取开关数据

WBOY
Release: 2016-06-06 20:14:50
Original
1444 people have browsed it

通过二进制来保存开关数据可以节省不少空间,尤其在保存大量数据的时候很有价值。总的来说有三种操作需要实现,如下: [代码片段]

通过二进制来保存开关数据可以节省不少空间,尤其在保存大量数据的时候很有价值。总的来说有三种操作需要实现,如下:

$original = 345;//101011001 function open($original,$position){ $data = 10 ?1:0; } echo decbin($original),PHP_EOL; echo decbin(open($original,2)),'|open|',2,PHP_EOL; echo decbin(close($original,3)),'|close|',3,PHP_EOL; echo decbin(get($original,4)),'|get|',4,PHP_EOL; vagrant@precise64:/var/www/test/curl$ php -f t.php 101011001 101011101|open|2 101010001|close|3 1|get|4 ,
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template