Use PHP code to implement a directory navigation function. Add a hyperlink to the file with a specified extension in the specified directory. It is a very practical function. Friends in need can refer to it.
The following code is implemented: Add hyperlinks to the files with the specified extension in the specified directory, and you can also ignore certain specified files without navigation. <?php /** * 遍历目录 文件导航 * by 程序员之家 bbs.it-home.org */ function navbar(){ $files = dir("."); //指定目录 $pipe = " | "; //管道符 //遍历目录中所有文件 while ($current = $files->read()) { //ignor all files not of htm type. if (strpos($current, "php")!= FALSE) //设定PHP文件被导航 //忽略自己(如 index.html) { if (strpos($current, "ndex") == FALSE) { print ""; print $current; print ""; print $pipe; }; }; }; }; //调用函数 navbar() ?> Copy after login |