클래스 선언에 표현식을 사용할 수 없습니다.
내가있는 경로를 통과하는 제안 :
public function __construct($path)
{
$this->debug_path = $path;
}
적 경로를 변경하려는 경우에 당신에게 더 많은 유연성을 제공, 당신은 당신이 전달 그냥 뭐, 일정을 변경할 필요가 없습니다
합니다.
다른 경로를 가진 개체를 여러 개 만들 수도 있습니다. 자동 로더 클래스 인 경우 여러 디렉토리를로드하려는 경우 유용합니다.
$autoloader = new Autoload(dirname(SYS_PATH));
$autoloader->register_loader();
class Autoload
{
public $include_path = "";
public function __construct($include_path="")
{
// Set the Include Path
// TODO: Sanitize Include Path (Remove Trailing Slash)
if(!empty($include_path))
{
$this->include_path = $include_path;
}
else
{
$this->include_path = get_include_path();
}
// Check the directory exists.
if(!file_exists($this->include_path))
{
throw new Exception("Bad Include Path Given");
}
}
// .... more stuff ....
}
그리고 의견은 다시 작성하지 않고 프로젝트에서 소스 코드를 제공했다는 의미입니다. 예! –
좋은 물건, 고맙습니다. – JasonDavis
get_include_path()는 OS 특정 경로 구분 기호로 구분 된 여러 경로를 반환 할 수 있습니다. 따라서 다중 경로가 정의되었지만 개별적으로 유효한 경로 인 경우 file_exists에 대한 호출이 실패합니다. –