我有页面 main.html,它是特定服务器的客户端应用程序。main.php 是一个包含三个框架的窗口。
main.html
<frameset frameborder=no border=0>
<frame name='top1' src='top1.php' frameborder=no scrolling=no>
<frame name='top2' src='top2.php' frameborder=no scrolling=no>
<frame name='firstpage' src='firstpage.php' frameborder=no scrolling=auto>
</frameset>
第一页.php
<?php
....
....
require_once("connection.php");
// connection.php is a class which opens a socket and establishes with another server.
set_time_limit(0);
ignore_user_abort();
function parse($line) {
//parses $line returns $a which contains some data etc
....
return $a;
}
$connect= new Connection();
.....
$line=$connect->socket_read(1028);
.....
while ($i<200) {
$GLOBALS[userdata][$i]=parse($line);
.......
}
?>
firstpage.php 是一个大脚本,出于易读性的原因,我已经修剪了 firstpage.php 的大部分内容。connect.php 和 firstpage.php 完全按照我想要的方式工作。
我需要在 top1.php 和 top2 中提供 $GLOBALS[userdata] 以进行进一步处理。无论如何我可以访问 $GLOBALS[userdata] 而无需再次实例化 connect.php 吗?(我希望在 top1.php 和 top2.php 中进行的数据处理不能在 firstpage.php 中完成,原因我无法在此讨论。)我无法重新实例化 connect.php,因为从服务器到 firstpage.php 的数据将不会被我的服务器反感。
我已经意识到,由于 firstpage.php 无限运行 $GLOBALS 没有被写入。在 $GLOBALS[userdata][$i]=parse($line); 之后立即尝试 session_write_close 在while循环中。但这并没有帮助。
我还发现top1.php、top2.php和firstpage.php中的SESSIONID是一样的。
谁能指出我正确的方向?
谢谢!!