PHP网站图
A. 如何用php实现网页截图
<?php
set_time_limit(60);
//截屏
$im = imagegrabscreen();
imagepng($im, "snap1.png");
//抓取IE窗口
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "snap2.png");
$im = imagegrabscreen();
//抓取IE窗口及窗口内容(IE为例)
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www..com");
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "snap3.png");
// IE全屏模式
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://www..com");
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "snap4.png");
//生成网站缩略图
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://www..com");
while ($browser->Busy) {
com_message_pump(4000); //等待4秒
}
$im = imagegrabwindow($handle, 0); //抓取网页图像,需要php5.2.2以上版本的支持
$browser->Quit();
$new_img = imagecreatetruecolor(200,150);
imageresampled($new_img,$im,0,0,0,0,200,150,1024,768);
imagejpeg($new_img , 'snap5.jpg',100);
imagedestroy($new_img);
echo "Done!";
?>
B. php如何制作网站地图
就是将你网站的链接,按子父级存到数据库里,然后在查出来生存一个结合z-tree生成网站地图
C. PHP怎样做网站地图
可以使用sitemap,也可以将网站主要栏目按照类别进行划分,生成地图
D. 用PHP实现网页图片,而且每次刷新都要显示一张不同图片
将图片名称存数组, 写个刷新事件,每次随机去数组里面的值 再拼接地址
这里会使用到三个文件:
connect.php:连接数据库
test_upload.php:执行sql语句
upload_img.php:上传图片并压缩
三个文件代码如下:
连接数据库:connect.php
<?php
$db_host='';
$db_user='';
$db_psw='';
$db_name='';
$db_port='';
$sqlconn=newmysqli($db_host,$db_user,$db_psw,$db_name);
$q="setnamesutf8;";
$result=$sqlconn->query($q);
if(mysqli_connect_errno()){
printf("Connectfailed:%s ",mysqli_connect_error());
exit();
}
?>
当然使用一些封装的数据库类也是可以的。
执行SQL语句:test_upload.php
<?php
require("connect.php");
require("upload_img.php");
$real_img=$uploadfile;
$small_img=$uploadfile_resize;
$insert_sql="insertintoimg(real_img,small_img)values(?,?)";
$result=$sqlconn->prepare($insert_sql);
$result->bind_param("ss",$real_img,$small_img);
$result->execute();
?>
上传图片并压缩:upload_img.php
<?php
//设置文件保存目录
$uploaddir="upfiles/";
//设置允许上传文件的类型
$type=array("jpg","gif","bmp","jpeg","png");
//获取文件后缀名函数
functionfileext($filename)
{
returnsubstr(strrchr($filename,'.'),1);
}
//生成随机文件名函数
functionrandom($length)
{
$hash='CR-';
$chars='';
$max=strlen($chars)-1;
mt_srand((double)microtime()*1000000);
for($i=0;$i<$length;$i++)
{
$hash.=$chars[mt_rand(0,$max)];
}
return$hash;
}
$a=strtolower(fileext($_FILES['filename']['name']));
//判断文件类型
if(!in_array(strtolower(fileext($_FILES['filename']['name'])),$type))
{
$text=implode(",",$type);
$ret_code=3;//文件类型错误
$page_result=$text;
$retArray=array('ret_code'=>$ret_code,'page_result'=>$page_result);
$retJson=json_encode($retArray);
echo$retJson;
return;
}
//生成目标文件的文件名
else
{
$filename=explode(".",$_FILES['filename']['name']);
do
{
$filename[0]=random(10);//设置随机数长度
$name=implode(".",$filename);
//$name1=$name.".Mcncc";
$uploadfile=$uploaddir.$name;
}
while(file_exists($uploadfile));
if(move_uploaded_file($_FILES['filename']['tmp_name'],$uploadfile))
{
if(is_uploaded_file($_FILES['filename']['tmp_name']))
{
$ret_code=1;//上传失败
}
else
{//上传成功
$ret_code=0;
}
}
$retArray=array('ret_code'=>$ret_code);
$retJson=json_encode($retArray);
echo$retJson;
}
//压缩图片
$uploaddir_resize="upfiles_resize/";
$uploadfile_resize=$uploaddir_resize.$name;
//$pic_width_max=120;
//$pic_height_max=90;
//以上与下面段注释可以联合使用,可以使图片根据计算出来的比例压缩
$file_type=$_FILES["filename"]['type'];
functionResizeImage($uploadfile,$maxwidth,$maxheight,$name)
{
//取得当前图片大小
$width=imagesx($uploadfile);
$height=imagesy($uploadfile);
$i=0.5;
//生成缩略图的大小
if(($width>$maxwidth)||($height>$maxheight))
{
/*
$widthratio=$maxwidth/$width;
$heightratio=$maxheight/$height;
if($widthratio<$heightratio)
{
$ratio=$widthratio;
}
else
{
$ratio=$heightratio;
}
$newwidth=$width*$ratio;
$newheight=$height*$ratio;
*/
$newwidth=$width*$i;
$newheight=$height*$i;
if(function_exists("imageresampled"))
{
$uploaddir_resize=imagecreatetruecolor($newwidth,$newheight);
imageresampled($uploaddir_resize,$uploadfile,0,0,0,0,$newwidth,$newheight,$width,$height);
}
else
{
$uploaddir_resize=imagecreate($newwidth,$newheight);
imageresized($uploaddir_resize,$uploadfile,0,0,0,0,$newwidth,$newheight,$width,$height);
}
ImageJpeg($uploaddir_resize,$name);
ImageDestroy($uploaddir_resize);
}
else
{
ImageJpeg($uploadfile,$name);
}
}if($_FILES["filename"]['size'])
{
if($file_type=="image/pjpeg"||$file_type=="image/jpg"|$file_type=="image/jpeg")
{
//$im=imagecreatefromjpeg($_FILES[$upload_input_name]['tmp_name']);
$im=imagecreatefromjpeg($uploadfile);
}
elseif($file_type=="image/x-png")
{
//$im=imagecreatefrompng($_FILES[$upload_input_name]['tmp_name']);
$im=imagecreatefromjpeg($uploadfile);
}
elseif($file_type=="image/gif")
{
//$im=imagecreatefromgif($_FILES[$upload_input_name]['tmp_name']);
$im=imagecreatefromjpeg($uploadfile);
}
else//默认jpg
{
$im=imagecreatefromjpeg($uploadfile);
}
if($im)
{
ResizeImage($im,$pic_width_max,$pic_height_max,$uploadfile_resize);
ImageDestroy($im);
}
}
?>
请按照现实情况更改connect.php,test_upload.php中对应的信息。
望采纳,谢谢。
F. php如何打开并显示出一张网页图片
你要的是不是单击图片,使图片在另一个页面显示吧<a
href="<?=图片地址?>"
target="_blank"><img
src="<?=图片地址?>"
border="0"/></a>
G. (php网站,图片管理)更新图片后,不能显示刚更新的图片
尝试在页面的图片url那里,就是<img src="">的时候,在url后面加一个随机数的参数
H. php网页图片如何调用
<img src="../../../index.jpeg">
I. php网站图片显示问题: 属性photoView{width: 480px; height: 320px也改了,
确认是不是缓存问题,可以换一个浏览器试试,也可以打开调试工具,查看图片的具体属性
J. PHP网站图片代码问题
没有的,只能复制粘贴修改再复制粘贴修改,写代码本来就是一个量的问题,光想着方便快捷可不行,想想晚上大半夜在公司加班,都要睡着了 手指还在不停的敲,这种境界需要练习的,手指自然反应,基础代码就不需要记了