Home  >  Article  >  Backend Development  >  Very good directory navigation file php code_PHP tutorial

Very good directory navigation file php code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:23:30918browse

Although this code is short, it is very practical. It can easily create a hyperlink to the file with the specified suffix name in the directory you specify, and it can be set so that the homepage of the specified directory will not be navigated.

function navbar(){
$files = dir("."); //Specify directory
$pipe = " | "; //Pipe character
//Search all files in the directory through the following loop
while ($current = $files->read()) {
//ignor all files not of htm type.
if (strpos($ current, "php")!= FALSE) //Files with the suffix PHP will be navigated
//Ignore themselves (such as index.html)
{ if (strpos($current, "ndex") == FALSE)
{
print "print $current;
print ">";
print $current;
print "";
print $pipe;
} ;
};
};
};
navbar() //Call function
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532217.htmlTechArticleAlthough this code is short, it is very practical. It can easily create files with the specified suffix name in the directory you specify. Hyperlink, and can be set so that the specified directory homepage will not be navigated. ...
Statement:
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