欢迎资源ID#5

Mal*_*loc 0 php command-line

当我尝试读取txt文件的内容时,我不断收到此错误:

index.php文件:

<?php
            $handle = fopen ("php://stdin","r");
            $line = fgets($handle);
            fwrite(STDOUT, "Welcome $handle"); 
            ?>
Run Code Online (Sandbox Code Playgroud)

在命令行中我做: cat texte.txt | php index.php

其中texte.txt包含一个名称.两个文件txt和php在同一个文件夹中.我曾经工作得很好,我不知道为什么这个错误出现在我的情况下.

Ign*_*ams 5

因为你习惯输出$line,而不是$handle.