php 文件流与二进制流_php 字符串、文件转化成二进制流文件

php 字符串、文件转化成二进制流文件

$file1 = 'F:/46.gif';

$file2 = 'F:/test.txt';

$file3 = 'F:/47.gif';

$size = filesize($file1);

echo '文件大小为:'.$size;

echo "\n
转化为二进制 ...";

$content = file_get_contents($file1);

$content = bstr2bin($content);

$fp = fopen($file2, 'w');

fwrite($fp, $content);

fclose($fp);

$size2 = filesize($file2);

echo '转化成二进制后文件大小为:'.$size2;

$content = bin2bstr($content);

$fp = fopen($file3, 'w');

fwrite($fp, $content);

fclose($fp);

function bin2bstr($input)

// Convert a binary expression (e.g., "100111") into a binary-string

{

if (!is_string($input)) return null; // Sanity check

// Pack into a string

$input = str_split($input, 4);

$str = '';

foreach ($input as $v)

{

$str .= base_convert($v, 2, 16);

}

$str =  pack('H*', $str);

return $str;

}

function bstr2bin($input)

// Binary representation of a binary-string

{

if (!is_string($input)) return null; // Sanity check

// Unpack as a hexadecimal string

$value = unpack('H*', $input);

// Output binary representation

$value = str_split($value[1], 1);

$bin = '';

foreach ($value as $v)

{

$b = str_pad(base_convert($v, 16, 2), 4, '0', STR_PAD_LEFT);

$bin .= $b;

}

return $bin;

}

相关文档:

转自: http://www.phpsoho.com/article/php/200809/09-239.html

如果 Web 应用程序中的一个特性需要超过 1 秒或 2 秒才能完成,那么应该怎么办?需要某种离线处理解决方案。学习几种对 PHP 应用程序中长时间运行的作业进行离线服务的方法。

大型的连锁店有一个大问题。每天,在每家商店会发生数千次交易� ......

how to install apache, PHP and MySQL on Linux

This tutorial explains the installation of Apache web server, bundled

with PHP and MySQL server on a Linux machine. The tutorial is primarily for SuSE

9.2, 9.3, 10.0 & 10.1, but most of the steps ought to be valid for all

Linux-like operating ......

转自:http://www.phpq.net

准备:

1、一台安装好的 Windows 2003 服务器,并且已经安装了 IIS 6。

2、下载 windows 版的 PHP 二进制压缩包。

安装:

解压缩 PHP 二进制压缩包到 C:\php 目录下(这里假设 C: 盘是系统盘,即安装了Windows 系统的盘,如果系统盘是 D:

盘,则解压缩到 D:\php 目录下,以此类推,下 ......

转自:http://www.ccvita.com

;;;;;;;;;;;;;;

;; 简介 ;;

;;;;;;;;;;;;;;

; 本文并非是对英文版 php.ini 的简单翻译,而是参考了众多资料以后,结合自己的理解,增加了许多内容,

; 包括在原有 php.ini 基础上增加了一些实用模块的配置说明,同时对文件内容的安排进行了调整。

; 由于作者不喜欢 no-free 的玩意儿� ......

问题一:cacti如法正常登录,没有报PHP程序错误

解决过程解决过程:开启PHP报错显示(在调试时,一直卡在这儿,由于是服务器上,没有开启报错程序)display_errors = On

发现报Warning: session_start() [ ......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值