Home > Backend Development > PHP Tutorial > PHP implementation code of directory navigation file

PHP implementation code of directory navigation file

WBOY
Release: 2016-07-25 09:00:26
Original
1201 people have browsed it
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


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template