php专区

 首页 > php专区 > PHP进阶 > 网络编程 > php页面静态刷新

php页面静态刷新

分享到:
【字体:
导读:
         摘要:RequirementsWorkswithApache-1.3.14/PHP4.0.3pl1serverandVariousNetscapeclients.Probablymanyotherservercombos.TestedonNetscape4.7xand6.0/Mozilla.DoesNOTWORKWITHIE...

php页面静态刷新
Requirements
Works with Apache-1.3.14/PHP4.0.3pl1 server and Various Netscape clients. Probably many other server combos. Tested on Netscape 4.7x and 6.0/Mozilla.
Does NOT WORK WITH IE. Internet Exploiter does not support x-mixed-replace server-push as far as I know. If a browser has "MSIE" in its User-Agent string the script will display one image and exit.

Update 20020108: Poked around freshmeat for a bit and found Andy Wilcock's Cambozola java applet which seems to work well with my php script to make the stream viewable under IE. Beware that the current version doesn't work under "Name-based" virtual hosts but I'll have a patch for it soon.
Source
Download

$file = "./latest.jpg";
$sep = "gIrLsKiCkAsSiTsAySsOoNaTsHiRt";

if (ereg(".*MSIE.*",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]))
{
# If IE, spit out one pic and exit
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-type: image/jpeg");
header("Content-size: " . filesize($file));
readfile($file);
}
else
{
# if not IE, give the browser a try
header("Content-Type: multipart/x-mixed-replace; boundary=$sep");
print "--$sepn";
do {
print "Content-Type: image/jpegnn";
readfile($file);
print "n--$sepn";
flush();
$mt = filemtime($file);
do {
sleep (1);
# we won't output the same image twice.
clearstatcache();
} while ($mt == filemtime($file));
} while (1);
}
?>


Make sure there are no blank lines outside the in your script. That will cause screwey headers to be sent too soon.
Reference the script in your HTML page as if it was an image:



Use this bit of PHP on the page that references the image to compensate for IE's lack of "innovation":


if (ereg("MSIE",$HTTP_SERVER_VARS["HTTP_USER_AGENT"])) {
echo "n";
}
?>

php页面静态刷新
分享到:
smarty实例教程
smarty实例教程 smarty实例教程(1)一、什么是smarty?smarty是一个应用PHP写出来的模板PHP模板引擎,它供给了逻辑与外在内容的分别,简略的讲,目标就是要应用PHP程序员同美工分离,应用的程序员转变程序的逻辑内容不会影响到美工的页面设计,美工重新修正页面不会影响到程序的程序逻辑,这在多人合作的项目中显的尤为重要。 ...
Php利用java解析xml
Php利用java解析xml 请先安装JAVA的执行环境与PHP结合,具体参考http://www.phpx.com/happy/thr78795.html  或者下载http://www.javax.org/download/php_java.rar  里面我写有个readme.txt说明文档,这个压缩包是个简单的例子。  要下载我的JAVA源码请到http://www.javax.org/download/JavaXml.rar  有其他问题请到h...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……