include_once("./_common.php"); 대체하기 > 그누보드5 팁자료실

그누보드5 팁자료실

include_once("./_common.php"); 대체하기 정보

include_once("./_common.php"); 대체하기

본문

_common.php을 만들지 않고 아래 코드를 직접 넣어서 사용.

또는 _common.php의 내용에 넣어서 사용.


<?php
function find_common_php() {
    $current_dir = dirname(__FILE__);
    $parent_dir = "../";
    $count = 0;
    while (!file_exists($current_dir . "/common.php")) {
        $current_dir = dirname($current_dir);
        $count++;
        if ($current_dir === '/' || $current_dir === '.') {
            break;
        }
    }
    return $count;
}
$up_count = find_common_php();
$include_path = str_repeat('../', $up_count) . 'common.php';
include_once($include_path);
추천
8
  • 복사

댓글 10개

© SIRSOFT
현재 페이지 제일 처음으로