直接上代码:
<?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>