<?$n1 =date("d");$fh = opendir ("./a/"); 
$q = readdir ($fh);while ($q){
$b1 = substr ($q,-10,2);if ($n1 == $b1){
echo "$q";}$q = readdir ($fh);
}
?>
我现在想用fopen打开$q所表示的文件,请问怎么打开啊 谢谢

解决方案 »

  1.   

    $n1 =date("d");
    $dh = opendir ("./");while ($file = readdir($dh)){
        $c = substr($file,-10,2);
        if ($c == $n1) {   // 打开,并且读取文件内容
            $handle = fopen($file);
            $contents = fread($handle, filesize ($filename));
            fclose($handle);
        }
    }
    closedir($dh);
      

  2.   

    <?
    $n1 =date("d");
    $dh = opendir ("./a/");while ($file = readdir($dh)){
        $c = substr($file,-10,2);
        if ($c == $n1) {   // 打开,并且读取文件内容
            $handle = fopen($file);
            $contents = fread($handle, filesize ($filename));
            fclose($handle);
        }
    }
    closedir($dh);
    ?>
    怎么结果是这样的啊  谁能帮忙改改么 谢谢
    Warning: fopen() expects at least 2 parameters, 1 given in /var/www/html/lyr/bb.php on line 8Warning: fread(): supplied argument is not a valid stream resource in /var/www/html/lyr/bb.php on line 9Warning: fclose(): supplied argument is not a valid stream resource in /var/www/html/lyr/bb.php on line 10
      

  3.   

    $filename = "/usr/local/something.txt";
    $handle = fopen ($filename, "r");
    $contents = fread ($handle, filesize ($filename));
    fclose ($handle);
      

  4.   

    <?php
    $handle = fopen ("/home/rasmus/file.txt", "r");
    $handle = fopen ("/home/rasmus/file.gif", "wb");
    $handle = fopen ("http://www.example.com/", "r");
    $handle = fopen ("ftp://user:[email protected]/somefile.txt", "w");
    ?> 
    fopen要两个参数,你只给了一个,第二个是打开文件的模式。