[PHP-users 31874] Re: カウントダウン表示がうまくいかない

ISHIDA Akio iakio @ mono-space.net
2007年 4月 9日 (月) 16:58:48 JST


こんにちは。石田@苫小牧市と申します。

余談ぎみですが、こんな方法もあるそうです。
long-lived HTTP connectionでJavaScriptをちょっとずつflushしながら
出力するという方法です。

http://ajaxpatterns.org/HTTP_Streaming#Solution
デモ:http://ajaxify.com/run/streaming/

07/04/09 に ymorii<yo-morii @ sdl.hitachi.co.jp> さんは書きました:
> Moriiと申します。
>
> もう解決しているようですが、
> 「PHPだけで」ということで以下のような解決方法はいかがでしょうか。
>
> <?
>   for( $i = 10; $i >=0; $i-- ){
>         ob_start();
>         printf ("<div id='OutArea' style='position: absolute; left:100px;
> top:100px;background-color:#fff;text-align:right;'>%s あと %02d秒 </div>",
> date('h:i:s'), $i);
>         flush();
>         sleep(1);
>         ob_end_flush();
>         //ob_end_clean();
>   }
> ?>
>
> 文字列を同じ場所に表示すると文字がかぶるので、
> "background-color"で白く塗っています。
>
-- 
ISHIDA Akio <iakio @ mono-space.net/ishida @ cycleof5th.com>


PHP-users メーリングリストの案内