php获取原图片
<?php
/*
获取远程图片函数
*/
function GrabImage($url,$filename=""){
//若url为空返回false,无地址
if($url=="") return false;
//若$filename为空
if($filename=="") {
$ext=strrchr($url,"."); //获取"."加后缀
if($ext!=".gif"&&$ext!=".jpg"&&$ext!=".png") return false;
$filename=date("YmdHis").$ext;
}
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img);
$fp2=@fopen($filename,"a");
fwrite($fp2,$img);
fclose($fp2);
return $filename;
}
$img=GrabImage("http://www.google.com/intl/en_ALL/images/logo.gif","logo.gif");
if($img){
echo '<img src="'.$img.'" mce_src="'.$img.'">';
}else{
echo "false";
}
?>
相关文档:
JAVA文件操作总结
File类
File f = new File(path);
path为实际路径,该路径可以是文件,或文件夹,也可以是不存在的。
f.exists() 可以判断该路是否存在。
f.isDirectory() 可以判断是否是文件夹。
f.mkdirs(); 递归创建文件夹
File和输入输出流之间纽带FileInutStream,FileOutputStream
URL url = new URL(strUr ......
该程序没有优化 只是最原始的程序 可以将其与flash结合起来!
与flash结合起来就是将php得到的地址和区域 打印出来再返回个flash端这么简单
<?php
$getIP="218.11.140.23"; // 这里是自己随便写的一个ip 实际时你还要通过程序得到这个ip
//只开始时查前三段
$subIPs=explode(".",$getIP);
$subIP=$sub ......
is_int函数对于FORM过来的数据是没有办法判断是否是整数的,因为FORM过来的是字符串。用is_numeric可以判断是否为数字类型,稍动 下手脚就可以判断是不是整数了
if(!is_numeric($jp_total)||strpos($jp_total,".")!==false){
echo "不是整数";
}else{
echo "是整数";
} ......
1. PHP可阅读随机字符串
此代码
将创建一个可阅读的字符串,使其更接近词典中的单
词,实用且具有密码验证功能。
/**************
[email=*@length]*@length[/email] - length of random string (must be a
multiple of 2)
**************/
function readable_random_string($length = 6){
$conso= ......
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
......