>  기사  >  백엔드 개발  >  PHP简略源码学习

PHP简略源码学习

WBOY
WBOY원래의
2016-06-13 13:17:571146검색

PHP简单源码学习
书上的源代码,好多个,每个都要敲就烦死了,
上网扣了段遍历文件的代码:http://www.web589.com/posts/808.html
作者写得不错的嘛,注释非常详细

<?php $var = "把当前目录下,所以文件以超链接形式给出<br /><br>";
	
	function directory($dir){
		$dp = opendir($dir);
		while($file = readdir($dp)){
			if($file !="." && $file !=".."){
				$path=$dir. "/". $file;	/* 取得目录路径 */
				
				if(is_dir($path)){	/* 判断是否有子目录 */
					directory($path);	/* 函数递归调用 */
					echo "<br><hr>";
				}
				else{ 
					printf('<a href="'.%24path.'" target="_blank">'.$path.'</a><br><br>');
				}
			}
		}
		closedir($dp);
	}
 
	directory(".");

?>



<?php phpinfo();
?>

   $number = "5";               # $number is a string
   $sum = 15 + $number;   	# Add an integer and string to produce integer
   print("$sum\n");
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사: PHP编码轨范 다음 기사: 怎么重定义常量