PHP 함수 get cwd depth()

1 개요[ | ]

PHP 함수 get_cwd_depth()
  • / 에서 현재작업디렉토리까지의 깊이를 알려주는 함수
function get_cwd_depth() {
	return count(explode('/', getcwd()))-1;
}

2 실행예시[ | ]

[root@zetawiki ~]# pwd
/root
[root@zetawiki ~]# cat get_cwd_depth.php 
<?php
function get_cwd_depth() {
	return count(explode('/', getcwd()))-1;
}
echo get_cwd_depth()."\n";
[root@zetawiki ~]# php get_cwd_depth.php 
1
[root@zetawiki ~]# cd /
[root@zetawiki /]# php /root/get_cwd_depth.php 
0
[root@zetawiki /]# cd /var/www/html
[root@zetawiki html]# php /root/get_cwd_depth.php 
3

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}