打开文件功能

时间:2019-06-23 16:14:56

标签: php

我有这样的代码。 但是问题是为什么不能输出...请给出建议,这段代码有什么问题

<?php

function randLine($fileName) {
    $fh = @fopen($fileName, "r");
    while (true) {
        $line = fgets($fh);
        if ($line == null) {
            break;
        }
    }
    fclose($fh);
    return $line;
}

$tes = randLine("list.txt");
$tes = str_replace(array("\n", "\r"), "", $tes);
echo $tes;

0 个答案:

没有答案