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網站圖片代碼問題
沒有的,只能復制粘貼修改再復制粘貼修改,寫代碼本來就是一個量的問題,光想著方便快捷可不行,想想晚上大半夜在公司加班,都要睡著了 手指還在不停的敲,這種境界需要練習的,手指自然反應,基礎代碼就不需要記了