查看完整版本: PHP程序指定目录里的指定后缀名文件为超连接

Kenny 2007-8-2 13:33

PHP程序指定目录里的指定后缀名文件为超连接

             <p><DIV id=contentTxt><P>用<a href="http://www.phpchina.com/javascript:;" onClick="javascript:tagshow(event, 'PHP');" target="_self"><u><strong>PHP</strong></u></a>实现的一个非常不错的目录导航文件的一个函数。</P><P>这个<a href="http://www.phpchina.com/javascript:;" onClick="javascript:tagshow(event, '%B4%FA%C2%EB');" target="_self"><u><strong>代码</strong></u></a>虽然短小,但很实用,它可以轻松建立你指定的目录里的指定后缀名文件的超连接,而且可以设定,不会将指定的目录首页导航。</P><DIV class=code><P>&lt;?php </P><P>function navbar()<BR>{ <BR>files = dir("."); //指定目录 <BR>pipe = " | "; //管道符 <BR>//通过以下的循环搜索目录中所有文件 <BR>while (current = files-&gt;read())<BR>{ <BR>//ignor all files not of htm type. <BR>if (strpos(current, "php\")!= FALSE) //设定后缀为PHP的文件将被导航 <BR>//忽略自己(如 index.html) <BR>{ </P><P>if (strpos(current, "ndex") == FALSE) <BR>{ <BR>print "&lt;a href='"; <BR>print current; <BR>print "'&gt;"; <BR>print current; <BR>print "&lt;/a&gt;"; <BR>print pipe; <BR>}; <BR>}; <BR>}; <BR>}; <BR>navbar() //调用函数 <BR>?&gt;</P>
页: [1]
查看完整版本: PHP程序指定目录里的指定后缀名文件为超连接
PageRank