在后台运行PHP脚本时显示图像 [英] Show image while in background PHP script executes

查看:54
本文介绍了在后台运行PHP脚本时显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiya家伙,


我有一个问题,我想显示页面上方的图像,而我的脚本在后台加载。

这是一个简单的脚本,用于检查我邮箱中的新邮件,因此它更像是GMAIL的加载栏,它在我们登陆邮箱之前显示。


伙计们,我该怎么办?因为我已经尝试了ob_start和ob_end_flush,但没有运气,我无法在脚本终止之前看到图像。整个数据一次性显示在浏览器中。我如何切片..


这段代码是这样的::


[PHP]

<?php

require_once(" lib / POP3.php");

include(''lib / mimeDecode.php'');

require_once(" ../ config / config.inc.php");


echo''< img src =" loader.gif" />'';



函数gmail($ em){

$ start = strrpos($ em," ;& lt;");

$ end = strrpos($ em,"& gt;");

$ len = $ start + 4 ;

$ email = substr($ em,$ len,$ end- $ len);

返回$ email;

}


/ ******************用于解析消息并将所需内容分成多个部分的功能*********** ******** /

函数parse_output(& $ obj,& $ parts){


if(!empty($ obj) - >部分)){

for($ i = 0; $ i< count($ obj-> parts); $ i ++)

parse_output($ obj - >零件[$ i],$ parts);


}其他{

$ ctype = $ obj-> ctype_primary。''/' '。$ obj-> ctype_secondary;

开关($ ctype){

case''text / plain'':

if( !empty($ obj-> disposition)AND $ obj-> disposition ==''attachment''){

$ parts [''attachments''] [] = $ obj-> ; body;

} else {

$ parts [''text''] [] = $ obj-> body;

}

break;


case''text / html'':

if(!empty($ obj-> disposition)AND $ obj-> disposition ==''attachment' '){

$ parts [''attachments''] [] = $ obj-> body;

} else {

$ parts [''html''] [] = $ obj-> body;

}

break;


default :


$ parts [''attachments''] [] = $ obj-> body;

$ parts [''attachments''] [ ''name''] = $ obj-> ctype_parameters [''name''];

}

}

}

/ ***************变量初始化************ /


$ user=''realin@domain.com'';

$ pass =''realin'';

$ host =''mail.domain.com'';

$ port =" 110";

$ commid =(int)" 6"

/ * @ var收件箱中的邮件总数

* /

$ nTotal ="" ;;


/ * @var收到的消息

* /

$ retr ="" ;;


$ my = array();

$ data = array();

$ obj =& new Net_POP3();


$ obj-> connect(" $ host"," $ port");

$ ret = $ obj-> login($ user,$ pass,''USER'');

if(is_object($ ret))

echo"无效的用户名/密码;


/ **** ******获取邮箱的办公室状态,即邮件数量,大小,UID ************* /

$ listing = $ obj- > getListing();



foreach($列为$ l){

$ id = $ l [" ; msg_id"];

$ head [$ id] = $ obj-> getParsedHeaders($ id);

$ body [$ id] = $ obj-> ; getMsg($ id);

}

?>

[/ PHP]

hiya guys,

I have a question, i want to display the image which is above the page, while my script loads in the background.
This is a simple script which check for new messages in my mailbox, so it is more like GMAIL''s loading bar which is shown just before we land into our mailboxes.

Guys, how do i do it ? Because i have tried ob_start and ob_end_flush, but with no luck i am unable to see the image before script terminates. The whole data is shown into browser in one go. How do i slice it ..

The piece of code is like this ::

[PHP]
<?php
require_once("lib/POP3.php");
include(''lib/mimeDecode.php'');
require_once("../config/config.inc.php");

echo ''<img src="loader.gif" />'';



function gmail($em){
$start=strrpos($em,"&lt;");
$end=strrpos($em,"&gt;");
$len=$start+4;
$email=substr($em,$len,$end-$len);
return $email;
}

/****************** Function to parse message and splits the needful into parts *******************/
function parse_output(&$obj, &$parts){

if(!empty($obj->parts)){
for($i=0; $i<count($obj->parts); $i++)
parse_output($obj->parts[$i], $parts);

}else{
$ctype = $obj->ctype_primary.''/''.$obj->ctype_secondary;
switch($ctype){
case ''text/plain'':
if(!empty($obj->disposition) AND $obj->disposition == ''attachment''){
$parts[''attachments''][] = $obj->body;
}else{
$parts[''text''][] = $obj->body;
}
break;

case ''text/html'':
if(!empty($obj->disposition) AND $obj->disposition == ''attachment''){
$parts[''attachments''][] = $obj->body;
}else{
$parts[''html''][] = $obj->body;
}
break;

default:

$parts[''attachments''][] = $obj->body;
$parts[''attachments''][''name'']=$obj->ctype_parameters[''name''];
}
}
}
/*************** Variable Initialization ************/

$user=''realin@domain.com'';
$pass=''realin'';
$host=''mail.domain.com'';
$port="110";
$commid=(int)"6";
/*@ var total number of messages
in the inbox */
$nTotal="";

/* @var Messages which are
being retrieved */
$retr="";


$my=array();
$data=array();
$obj=&new Net_POP3();

$obj->connect("$host","$port");
$ret=$obj->login($user , $pass,''USER'' );
if(is_object($ret))
echo "Invalid Username/Password";

/********** Gets the office status of the mailbox, viz number of messages,size,UID *************/
$listing=$obj->getListing();



foreach($listing as $l){
$id=$l["msg_id"];
$head[$id]=$obj->getParsedHeaders($id);
$body[$id]=$obj->getMsg($id);
}
?>
[/PHP]

推荐答案

em){
em){

start = strrpos(
start=strrpos(


em,"& lt;");
em,"&lt;");


这篇关于在后台运行PHP脚本时显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆