直接上代碼:
<?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
設置頁面背景(全屏,內容透明背景)
<?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
?>
<html>
<head>
<title>123</title>
<style type="text/css">
body{
background:url(<?php echo bg();?>) ;
background-size:100% 100%;
background-attachment:fixed;
}
#la{
background:rgba(255,255,255,0.8);
margin-left:10%;
margin-right:10%;
text-align:center;
}
</style>
</head>
<body>
<div id="la">
<h1>aaa</h1>
<pre>
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
?php
function bg(){
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx='.rand(0,5).'&n=1'); //從bing獲取數據
$reg = "/<url>.*?<\/url>/";
preg_match($reg, $str, $matches);
$b = substr($matches[0],0,-6);
$new = preg_replace("/<url>|<\/url>/is","", $b);
$imgurl='http://cn.bing.com'.$new;
return $imgurl;
}
————————————————
版權聲明:本文爲CSDN博主「丨Daisy丨」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Daisy_Journal/article/details/103135054
</pre>
</div >
</body>
</html>