duangewu5234 2015-03-15 16:34
浏览 216

file_get_contents()函数是否记住文件中的数据,即使它被删除了?

Some spooky things happens or at least it seems to me. Namely, I have a simple script that reads text from another file.

  $contents = @file_get_contents('/private/filetest01.txt');
  if($contents===false){
  echo "Sorry. There was a problem reading the file.";}
  else{
  echo $contents;

Everything seemed ok, until I actually deleted filetest01.txt expecting some changes, but the script continued to echo text - why is this? Even the file where text was doesn't exist anymore. So to be clear:

$contents = @file_get_contents('/private/filetest01.txt');

takes the file from filetest01.txt, and after I had deleted filetest01.txt, my script continued to remember data and echoing text. Not just that, but after deleting I made new filetest01.txt, with another text, but my script continues to print first, seminal text. I thought it was maybe some browser thing, but, after I pasted address in another browser, the behavior of the script was the same.

What I did next: I deleted file again. My /private/ folder is empty. I open completely new browser, made completely new script, which function is just to check does deleted file exists.

<?php 
if (file_exists('/private/filetest01.txt')){
echo "yes";
}else{echo "no";}
?>

It prints "yes". Can someone tell me, what is it all about?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题