我一直在本地開發一個使用Codeigniter的自定義CMS,並且我已經到了需要將其上傳到臨時服務器以進行更多測試的地步。PHP在本地工作,而不是在服務器
除了使用小部件系統的網站的側欄部分以外的所有內容都可以使用。我最初認爲這只是PHP版本之間的差異,因爲我在本地運行5.4.4,服務器是5.3。將服務器升級到5.4.7後,側邊欄仍未顯示。我沒有錯誤,只是沒有顯示。
這是小工具庫代碼:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Widgets {
private $_ci;
protected $parser_enable = FALSE;
public function __construct() {
$this->widgets();
}
public function widgets(){
$this->_ci =& get_instance();
}
public function build($view,$data=array()){
$view = get_class($this).'/'.$view;
$subdir = '';
if (strpos($view, '/') !== FALSE)
{
// explode the path so we can separate the filename from the path
$x = explode('/', $view);
// Reset the $class variable now that we know the actual filename
$view = end($x);
// Kill the filename from the array
unset($x[count($x)-1]);
// Glue the path back together, sans filename
$subdir = implode($x, '/').'/';
}
$widget_view = APPPATH.'widgets/'.$subdir.'views/'.$view.EXT;
if(file_exists($widget_view)){
$widget_view = '../widgets/'.$subdir.'views/'.$view.EXT;
if($this->parser_enable){
$this->_ci->load->library('parser');
return $this->_ci->parser->parse($widget_view,$data,TRUE);
}
else{
return $this->_ci->load->view($widget_view,$data,TRUE);
}
}
return FALSE;
}
public function __get($var) {
static $ci;
isset($ci) OR $ci = get_instance();
return $ci->$var;
}
}
做任何事情跳出來,可能導致其無法顯示?
有什麼我應該看看,使其兼容,如服務器模塊?服務器上可能會對此產生什麼影響?
編輯:
我的小部件存在於以下路徑:
/public_html/application/widgets/recent_news/views/view.php
的$widget_view = 'widgets/'.$subdir.'views/'.$view.EXT;
變量返回widgets/Recent_news/views/view.php
這是越來越傳遞到:
if(file_exists($widget_view)){
return $this->_ci->load->view($widget_view,$data,TRUE);
}
應用程序路徑$ widget_view在暫存服務器上似乎不正確,所以file_exists()返回false並且不加載視圖(其中w無論如何都應該有一個不正確的路徑)。
我似乎無法讓它讀取正確的路徑,有什麼建議嗎?
'的phpinfo();'看什麼,讓你 – Norse
我看到馬上的唯一事情是行$ widget_view =」 .. /部件/」。你確定這條道路是正確的嗎?您應該使用絕對路徑來確保。 – noel
@Norse除了版本,我應該注意什麼在phpinfo()? – Motive