
include_path는 PHP에서 파일을 호출할 때 사용하는 경로를 의미합니다. 만약 include_path를 설정하지 않았을 때, PHP는 시스템의 기본 경로에서 파일을 호출합니다.
include_path를 설정했을 때, PHP는 설정된 경로에서부터 파일을 호출합니다. 예를 들어, includes라는 디렉토리가 있는 경우, include_path를 설정했을 때, PHP는 includes라는 디렉토리에서 파일을 호출합니다.
아래 예제를 보면, includes 디렉토리에 file.php가 없을 때, PHP는 includes 디렉토리에서 file.php를 호출하고, 없으면 오류를 발생시킵니다.
#hostingforum.kr
php
include_path = /var/www/html/includes
include 'file.php';
include_path를 설정할 때, 경로를 여러 개 설정할 수 있습니다. 아래 예제를 보면, includes 디렉토리와 plugins 디렉토리에서 file.php를 호출합니다. 만약 file.php가 includes 디렉토리에 없을 때, PHP는 plugins 디렉토리에서 file.php를 호출합니다.
#hostingforum.kr
php
include_path = /var/www/html/includes:/var/www/html/plugins
include 'file.php';
include_path를 설정할 때, 디렉토리 경로를 절대 경로로 설정할 수 있습니다. 아래 예제를 보면, includes 디렉토리, plugins 디렉토리, 절대 경로의 plugins 디렉토리에서 file.php를 호출합니다.
#hostingforum.kr
php
include_path = /var/www/html/includes:/var/www/html/plugins:/absolute/path/to/plugins
include 'file.php';
결론적으로, include_path를 설정하면 PHP가 파일을 호출할 때 사용하는 경로를 지정할 수 있습니다. 여러 경로를 설정할 수 있으며, 절대 경로를 사용할 수도 있습니다.
2025-06-20 00:39