易截截图软件、单文件、免安装、纯绿色、仅160KB

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

$file1 = 'F:/46.gif';
$file2 = 'F:/test.txt';
$file3 = 'F:/47.gif';
$size = filesize($file1);
echo '文件大小为:'.$size;
echo "\n<br>转化为二进制 ...";
$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;
}


相关文档:

《PHP 与 MySQL Web 开发》读书笔记 (一)

概述
1.PHP 是什么?
   PHP 是服务器端解释的脚本语言,它是目前最流行的 web 编程语言之一。  在一个 HTML 页面中可以嵌入PHP代码,这些代码在每次页面访问时执行。PHP 代码将在 Web 服务器中被解释并且生成 HTML或者访问者看到其他输出结果。
2.My SQL 是什么?
   My SQL 是基于 SQL 的完 ......

how to install apache, PHP and MySQL on Linux 2

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

PHP初学

   现在对PHP感觉越来越顺手了,对HTML的标签越来越熟悉了,可是对PHP的插件的认识还为之甚少。
   但是,说实话,目前的我貌似也不需要使用PHP的插件,用插件的目的可能是为了显得比较牛吧,呵呵。
   但是还是踏踏实实的学习吧,毕竟额的C++还没有学,对于PHP的封装和编程一点也不了解。 ......

php FILES数组的使用

$_FILES['myFile']['name']   客户端文件的原名称。 
$_FILES['myFile']['type']   文件的 MIME 类型,需要浏览器提供该信息的支持,例如"image/gif"。 
$_FILES['myFile']['size']   已上传文件的大小,单位为字节。 
$_FILES['myFile']['tmp_n ......

FastCGI 不完全高级指南(PHP版,Windows平台)

一、FastCGI是什么?
FastCGI是语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程保持在内存中并因此获得较高的性能。众所周知,CGI解释 器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在内存中并接受FastCGI进程管理器调度,则可以提供良好的性能、伸缩性、Fail- Over特性等等。
FastCGI的官 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号