PHP实现即时输出、实时输出内容方法


老生长谈了。。纯备忘

对于运行时间较长的PHP程序来说可能都需要即时输出内容来查看运行情况。

header(“Content-type:text/html;charset=utf-8″);

#设置执行时间不限时 set_time_limit(0);

#清除并关闭缓冲,输出到浏览器之前使用这个函数。 ob_end_clean();

#控制隐式缓冲泻出,默认off,打开时,对每个 print/echo 或者输出命令的结果都发送到浏览器。 ob_implicit_flush(1);


例,
ob_end_clean();

ob_implicit_flush(1);

while(1){

    //部分浏览器需要内容达到一定长度了才输出

    echo str_repeat("<div></div>", 200).'hello sjolzy.cn<br />';

    sleep(1);

    //ob_end_flush();

    //ob_flush();

    //flush();

}

按例子测试,达到了PHP即时实时输出内容的效果。

php实现window平台的checkdnsrr函数
PHP的自带checkdnsrr函数只在linux平台有效。使用惯了在window平台不能使用的话给兼容性带来麻烦。因此写了个checkdnsrr模拟函数在window平台环境使用。if(!fun

PHP验证信用卡卡号是否正确函数
可以使用以下PHP函数,验证一个卡号是否是信用卡:functionvalidateCard($cardnumber){$cardnumber=preg_replace("/D|s/","",$cardnumber);#stripanynon-digits$cardlength=strlen($cardnum

PHP编译安装时常见错误解决办法
Thisarticleispostonhttps://coderwall.com/p/ggmpfaconfigure:error:xslt-confignotfound.Pleasereinstallthelibxslt=1.1.0distributionyum-yinstalllibxslt-develconfigure:error:Couldnotfindnet-snmp-configbina