본문으로 바로가기

php 현재 폴더이름 알아내기

category 웹프로그래밍/PHP 2014. 3. 12. 13:01

바로윗 폴더이름을 알아내는 함수이다.

레프트메뉴나 탑메뉴에 on 클래스를 추가한다던가 할때 사용하면 좋다.

 

//php 바로위 폴더이름 알아내기 

function get_dirname() {
 $dir = getcwd(); // 현재 디렉토리명을 반환하는 PHP 함수이다.
 $temp = explode("/", $dir);
 $dirname = $temp[sizeof($temp)-1];

 return $dirname;
}

 

// http://qkrrjsgh.tistory.com/product/cmm/index.html -> cmm