file_get_contents读取不到session的原因

来源:互联网 发布:新浪php 面试 日志 编辑:程序博客网 时间:2024/06/06 04:02

例如有两个文件:

 

test1.php:

test2.php:

但是会发现test1.php的file_get_contents根本都读取不到test2.php的session.

 

原因如下:

file_get_contents,文件操作时需要打开句柄

默认的session是文件,也是需要打开一个句柄的

由于先打开句柄的那个没有关闭句柄,所以就造成了这种"阻塞"现象....