PHP进度条效果
用PHP实现进度条效果。
<?php
set_time_limit(0);
echo '<h2>正在安装,请稍后...</h2>',
'<div style="border:1px solid #000;width:500px;"><div id="progress_bar">loading...</div></div>';
for($i=1;$i<=100;$i++){
$width = '500';
$width = ceil(($i/100)*$width);
echo '<mce:script type="text/javascript"><!--
',
'var progress_bar = document.getElementById("progress_bar");',
'progress_bar.style.background="#ff0000";',
'progress_bar.style.width ="'.$width.'px";',
"progress_bar.innerHTML = '{$i}%';",
'
// --></mce:script>';
sleep(1);
flush();
}
echo 'done';
?>
相关文档:
<?php
$p=new ReflectionClass(类对象);
$constants=$p->getConstants();//const 定义常量
$properties=$p->getProperties();//所有变量属性
$methods=$p->getMethods();//所有方法
//全部以数组形势返回
?> ......
header()函数用来转向(redirect page)时,如果调用前有输出,比如echo或html标签,就会转向失败。
如果调用前有空行也会转向失败。
还有一个原因,就是注意你的php文件的字符编码。我遇到的情况是,当字符编码为UTF-8时,转向失败,改为ANSI时成功。具体原因不明,仅供参考。 ......
PHP
是我用过的语言中,最令人恼火的但同时也是最有趣的语言。我之所以说“令人恼火”主要是因为函数命名极其不一致。尽管我每天都要用到这些函数,我还是要想
一下“究竟是 str_pos 还是 strpos?是 str_split 还是
strsplit?”。另一方面,有时候可以用一行简单的代码就能解决一个难题。
下面 ......
Floating point precision
It is typical that simple decimal fractions like 0.1
or
0.7
cannot be converted into their internal binary
counterparts without a small loss of precision. This can lead to
confusing
results: for example, floor((0.1+0.7)*10)
will usually
return 7
......
<?php
/*
获取远程图片函数
*/
function GrabImage($url,$filename=""){
//若url为空返回false,无地址
if($url=="") return false;
//若$filename为空
if($filename=="") {
$ext=strrchr($url,"."); //获取"."加后缀
if($ext!=&qu ......