Php Access包括应用程序文件夹中的文件夹。
我使用的是CodeIgniter,我需要能够读取和/或包含一些html文件,所以我在应用程序文件夹中创建了一个includes目录 使用CI访问此目录的最佳方式是什么 在我的控制器中,我尝试过:Php Access包括应用程序文件夹中的文件夹。,php,codeigniter,error-handling,relative-path,Php,Codeigniter,Error Handling,Relative Path,我使用的是CodeIgniter,我需要能够读取和/或包含一些html文件,所以我在应用程序文件夹中创建了一个includes目录 使用CI访问此目录的最佳方式是什么 在我的控制器中,我尝试过: private $cms_temp_folder = APPPATH . 'includes/'; 但这给了我一个错误: Parse error: syntax error, unexpected '.', expecting ',' or '; 我的做法是正确的,还是应该以另一种方式进行?只能使用
private $cms_temp_folder = APPPATH . 'includes/';
但这给了我一个错误:
Parse error: syntax error, unexpected '.', expecting ',' or ';
我的做法是正确的,还是应该以另一种方式进行?只能使用文本或常量初始化类属性;不允许使用表达式 因此,必须在构造中对其进行初始化:
private $cms_temp_folder;
function __construct() {
$this->cms_temp_folder = APPPATH . 'includes/';
}
如果将路径放在配置文件中可能会更好,例如:
private $cms_temp_folder;
function __construct() {
$this->load->config('paths');
$temp_path = $this->config->item('temp_folder', 'paths');
$this->cms_temp_folder = ($temp_path == '') ? APPPATH . 'includes/' : APPPATH . $temp_path;
}
类属性只能使用文本或常量初始化;不允许使用表达式 因此,必须在构造中对其进行初始化:
private $cms_temp_folder;
function __construct() {
$this->cms_temp_folder = APPPATH . 'includes/';
}
如果将路径放在配置文件中可能会更好,例如:
private $cms_temp_folder;
function __construct() {
$this->load->config('paths');
$temp_path = $this->config->item('temp_folder', 'paths');
$this->cms_temp_folder = ($temp_path == '') ? APPPATH . 'includes/' : APPPATH . $temp_path;
}
类属性只能使用文本或常量初始化;不允许使用表达式 因此,必须在构造中对其进行初始化:
private $cms_temp_folder;
function __construct() {
$this->cms_temp_folder = APPPATH . 'includes/';
}
如果将路径放在配置文件中可能会更好,例如:
private $cms_temp_folder;
function __construct() {
$this->load->config('paths');
$temp_path = $this->config->item('temp_folder', 'paths');
$this->cms_temp_folder = ($temp_path == '') ? APPPATH . 'includes/' : APPPATH . $temp_path;
}
类属性只能使用文本或常量初始化;不允许使用表达式 因此,必须在构造中对其进行初始化:
private $cms_temp_folder;
function __construct() {
$this->cms_temp_folder = APPPATH . 'includes/';
}
如果将路径放在配置文件中可能会更好,例如:
private $cms_temp_folder;
function __construct() {
$this->load->config('paths');
$temp_path = $this->config->item('temp_folder', 'paths');
$this->cms_temp_folder = ($temp_path == '') ? APPPATH . 'includes/' : APPPATH . $temp_path;
}
你在哪里写的,在任何函数或类内声明中?这个问题似乎是离题的,因为它是关于语法错误的。你在哪里写的,在任何函数或类内声明中?这个问题似乎是离题的,因为它是关于语法错误的。你在哪里写的,在任何函数或类内声明中?这个问题似乎是离题的,因为它是关于语法错误的。你在哪里写的这个,在任何函数或类内声明中?这个问题似乎是离题的,因为它是关于语法错误的。