查看文件application/views//未找到..php
view file application/views//view..php not found
public static function view($name, array $vars = null){
if(preg_match('/\\/', $name)){
$view_data = explode('\', $name);
if(count($view_data) == 3)
$file = APP_PATH.DS.'views'.DS.$view_data[0].DS.$view_data[1].DS.'view.'.$view_data[2].'.php';
else
$file = APP_PATH.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php';
}
else{
$file = APP_PATH.DS.'views'.DS.'view.'.$name.'.php';
}
if(!is_readable($file)){
throw new Exception('view file application'.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php not found.');
}
else{
if(isset($vars)){
extract($vars);
}
require($file);
}
}
[21-Apr-2015 13:10:30 UTC] PHP Notice: Undefined variable: view_data in /home/realitycards/public_html/test/system/load.class.php on line 28
您的变量 $view_data
仅在第一个 if
语句中定义。在下面的 if
语句中,您似乎正在使用 $view_data
,即使它尚未设置。
if(!is_readable($file)){
throw new Exception('view file application'.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php not found.');
}
您需要在 else
语句中设置 $view_data
,或者在上述例外情况中,使用您已经设置的 $file
变量:
if(!is_readable($file)){
throw new Exception('view file '. $file .' not found.');
}
public static function view($name, array $vars = null){
if(preg_match('/\\/', $name)){
$view_data = explode('\', $name);
if(count($view_data) == 3)
$file = APP_PATH.DS.'views'.DS.$view_data[0].DS.$view_data[1].DS.'view.'.$view_data[2].'.php';
else
$file = APP_PATH.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php';
}
else{
$file = APP_PATH.DS.'views'.DS.'view.'.$name.'.php';
}
if(!is_readable($file)){
throw new Exception('view file application'.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php not found.');
}
else{
if(isset($vars)){
extract($vars);
}
require($file);
}
}
[21-Apr-2015 13:10:30 UTC] PHP Notice: Undefined variable: view_data in /home/realitycards/public_html/test/system/load.class.php on line 28
您的变量 $view_data
仅在第一个 if
语句中定义。在下面的 if
语句中,您似乎正在使用 $view_data
,即使它尚未设置。
if(!is_readable($file)){
throw new Exception('view file application'.DS.'views'.DS.$view_data[0].DS.'view.'.$view_data[1].'.php not found.');
}
您需要在 else
语句中设置 $view_data
,或者在上述例外情况中,使用您已经设置的 $file
变量:
if(!is_readable($file)){
throw new Exception('view file '. $file .' not found.');
}