This article mainly introduces the method of php simulation server to achieve autoindex effect, and analyzes the techniques of php operating URL and passing parameters with examples. It has certain reference value, friends in need can refer to it
The example in this article describes the method of php simulated server to achieve the autoindex effect. Share it with everyone for your reference. The specific implementation method is as follows:
1.PHP code is as follows:
The code is as follows:
<a href="?dir=<?php echo dirname($pwd)?>">../</a><br> <?php <br /> foreach ($it as $file){ <br /> if($file->isDir()) {<br> $fileSize = '_';<br> $fileName = $file->getFilename() . '/';<br> } elseif($file->isFile()) {<br> $fileSize = $file->getSize();<br> $fileName = $file->getFilename();<br> }<br> $date = date('Y-m-d H:i',$file->getCTime());<br> ?><a href="?dir=<?php echo $file->getRealPath()?>"><?php echo $fileName ?></a><?php echo str_pad($date, 60-strlen($fileName),' ',STR_PAD_LEFT)?><?php echo str_pad($fileSize,30,' ',STR_PAD_LEFT)?><br> <?php }?>
2. The operation effect is shown in the figure below:
I hope this article will be helpful to everyone’s PHP programming design.