可能要服务器协助实现。单单php不能执行程序的吧?

解决方案 »

  1.   

    程序可以执行exec("ls > a.txt");
    $filename = a.txt";$handle = fopen ($filename, "r");
    $contents = fread ($handle, filesize ($filename));
    fclose ($handle);
      

  2.   

    //PHP有几个都可以执行系统程序的函数,如果要处理输出结果还比较麻烦
    //system(),exec(),popen()
    //如果要处理好输出的结果,建议使用popen()<?
    $cmd = "ls";
    echo "<pre>". system($cmd) ."</pre>";
    ?>
      

  3.   

    打开apache配置文件。 想要列出的目录加上Options Indexs FollowSymLinks