라이브러리
[PHP] get_include_path - 현재 include_path 구성 옵션을 가져옵니다.
PHP의 get_include_path() 함수
PHP의 `get_include_path()` 함수는 현재 포함 경로를 반환합니다. 포함 경로는 PHP가 파일을 포함할 수 있는 디렉토리를 지정하는 경로입니다. 이 함수는 PHP의 `include_path` 설정 변수의 값을 반환합니다.
get_include_path() 함수의 사용법
`get_include_path()` 함수는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$path = get_include_path();
print($path);
포함 경로 설정하기
PHP의 포함 경로는 `include_path` 설정 변수를 사용하여 설정할 수 있습니다. `set_include_path()` 함수를 사용하여 포함 경로를 설정할 수 있습니다.
#hostingforum.kr
php
set_include_path('/var/www/html/lib:/usr/local/lib');
포함 경로에 디렉토리 추가하기
`get_include_path()` 함수로 현재 포함 경로를 가져온 후, 디렉토리를 추가할 수 있습니다.
#hostingforum.kr
php
$path = get_include_path();
$path .= ':/var/www/html/mylib';
set_include_path($path);
예제: PHP의 포함 경로 사용하기
다음 예제는 PHP의 포함 경로를 사용하여 라이브러리를 포함하는 방법을 보여줍니다.
#hostingforum.kr
php
// 포함 경로 설정하기
set_include_path('/var/www/html/lib:/usr/local/lib');
// 라이브러리를 포함하기
require_once 'MyClass.php';
// MyClass.php 파일을 포함한 후, MyClass 클래스를 사용할 수 있습니다.
$obj = new MyClass();
$obj->doSomething();
예제: PHP의 포함 경로 사용하기 (디렉토리 추가하기)
다음 예제는 PHP의 포함 경로를 사용하여 디렉토리를 추가하는 방법을 보여줍니다.
#hostingforum.kr
php
// 현재 포함 경로 가져오기
$path = get_include_path();
// 디렉토리를 추가하기
$path .= ':/var/www/html/mylib';
// 포함 경로 설정하기
set_include_path($path);
// 라이브러리를 포함하기
require_once 'MyClass.php';
// MyClass.php 파일을 포함한 후, MyClass 클래스를 사용할 수 있습니다.
$obj = new MyClass();
$obj->doSomething();
참고
* `get_include_path()`: PHP의 현재 포함 경로를 반환합니다.
* `set_include_path()`: PHP의 포함 경로를 설정합니다.
* `require_once`: PHP의 포함 함수입니다. 포함 경로에 지정된 디렉토리에서 파일을 포함합니다.
* `include_path`: PHP의 포함 경로를 설정하는 설정 변수입니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.