Home > php教程 > PHP源码 > 静态网页 浏览量更新及显示

静态网页 浏览量更新及显示

PHP中文网
Release: 2016-05-25 17:09:31
Original
1560 people have browsed it

代码

<?php
//db更新(update数据库或文件)
//db取出(select 浏览量)
$viewnum = "123456" //比如取出浏览量为123456
//补0(页面显示效果)
$viewnum = str_pad($viewnum,11,"0",STR_PAD_LEFT);
for($i=0;$i<=9;$i++)
{
        //把数字替换html标签 方便css操作
	$viewnum=str_replace($i,"<i class=&#39;n$i&#39;></i>",$viewnum);
}
?>
<?php header("Content-type: text/javascript");?>
document.write("<?php echo $viewnum;?>");   //输出
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template