如何从绝对路径向上移动一个文件夹?
文件结构:
/folder/
/folder/config.php
/folder/classes/test.php
Run Code Online (Sandbox Code Playgroud)
从test.php我想要include_once或require_once config.php -file.
我在test.php中尝试了这个,但它不起作用:
require_once(dirname(__FILE__) . '/../config.php');
Run Code Online (Sandbox Code Playgroud)
错误消息:*PHP致命错误:require_once():无法打开所需的'/loooong-path/classes/../test.php'*
我的点子:
我的控制器代码如下(application/controllers/registration.php):
callback_min_length[2] 是我尝试将值发送到辅助函数
// 加载助手 $this->load->helper(array('form', 'url', 'error'));
// Load library
$this->load->library('form_validation');
// Set form rules
$rules = array(
array(
'field' => 'firstName',
'label' => 'firstName',
'rules' => 'callback_min_length[2]|trim'
)
);
$this->form_validation->set_rules($rules);
// Set custom error messages
if ($this->form_validation->run() == FALSE)
{
$this->load->view('header');
$this->load->view('view_registration');
$this->load->view('footer');
}
else
{
$this->load->view('header');
$this->load->view('view_registration');
$this->load->view('footer');
}
Run Code Online (Sandbox Code Playgroud)我的自定义助手代码如下(application/helpers/error_helper.php):
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function min_length($str, $val) {
// Load CI instance to be able to load …Run Code Online (Sandbox Code Playgroud)