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

php下载文件相关资料

当下载文件需要与服务端交互时,就需要用脚本来实现,而不是单纯地链接到文件的地址
下载mp3文件的例子
<?php
$file_path = './data/upload/song/sample.mp3';
$file_name = 'sample.mp3';
$file_size = filesize($file_path);
header ( "Pragma: public" );
header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header ( "Cache-Control: private", false );
header ( "Content-Transfer-Encoding: binary" );
header ( "Content-Type:audio/mpeg MP3");
header ( "Content-Length: " . $file_size);
header ( "Content-Disposition: attachment; filename=".$file_name);
echo(file_get_contents($file_path));
exit;
?>
以下列表来自http://hi.baidu.com/zbzb /blog/item/643cd60021d25d11738b6530.html
Content-type 的说明 'application/andrew-inset',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'so' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'bcpio' => 'application/x-bcpio',
'vcd' => 'application/x-cdlink',
'pgn' => 'application/x-chess-pgn',
'cpio' => 'application/x-cpio',
'csh' => 'application/x-csh',
'dcr' => 'application/x-director',
'di


相关文档:

PHP 判断FORM来的数据是否为整数

is_int函数对于FORM过来的数据是没有办法判断是否是整数的,因为FORM过来的是字符串。用is_numeric可以判断是否为数字类型,稍动 下手脚就可以判断是不是整数了
if(!is_numeric($jp_total)||strpos($jp_total,".")!==false){
echo "不是整数";
}else{
echo "是整数";
} ......

PHP后台程序对LINUX信号的处理

PHP在运行的时候,直接kill掉,有肯能造成数据的丢失。幸好php模块,有针对signal的处理。
处理方式,首先检查有没有安装 PCNTL 模块
然后可以在一个包含文件中,添加以下代码
global $exitFlag;
$exitFlag = false;
// 增加linux信号量处理
if (DIRECTORY_SEPARATOR != '\\') {
    pcntl_signal(SI ......

21个实用便利的PHP代码

1. PHP可阅读随机字符串
此代码
将创建一个可阅读的字符串,使其更接近词典中的单
词,实用且具有密码验证功能。
/**************
[email=*@length]*@length[/email] - length of random string (must be a
multiple of 2)
**************/
function readable_random_string($length = 6){
    $conso= ......

PHP Floating point precision

Floating point precision
It is typical that simple decimal fractions like 0.1
or
0.7
cannot be converted into their internal binary
counterparts without a small loss of precision. This can lead to
confusing
results: for example, floor((0.1+0.7)*10)
will usually
return 7
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号