PHP致命错误:require()
我有一个网站,在我的本地主机上使用xampp完美工作,但是......我将它上传到几个免费网站托管(000webhost和hostinger),当我尝试打开它时,得到此消息:PHP致命错误:require()
Warning: require(core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7
Fatal error: require(): Failed opening required 'core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7
这是代码:
<?php
session_start();
$view = isset($_GET['view']) ? $_GET['view'] : 'index';
require_once('core/libs/smarty/Smarty.class.php');
require('core/models/class.Conexion.php');
if(file_exists('core/controllers/'.$view.'Controller.php')){
include('core/controllers/'.$view.'Controller.php');
}else {
include('core/controllers/errorcontroller.php');
}
?>
我检查了文件一个百倍,它是存在的。
我发现并试用了此解决方案:
- 更改需要包括:
Warning: include(core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7
Warning: include(): Failed opening 'core/libs/smarty/Smarty.class.php' for inclusion (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7
Fatal error: Class 'Smarty' not found in /home/u327900732/public_html/www/core/controllers/indexController.php on line 3
- 要求(CHDIR(目录名(FILE))的核心/库/ smarty的/ Smarty.class.php');
Warning: require(1core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7
Fatal error: require(): Failed opening required '1core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7
- 更改线7
require_once($ _ SERVER [ 'DOCUMENT_ROOT'] '/核心/库/ smarty的/ Smarty.class.php');
Warning: require_once(/home/u327900732/public_html/core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7
Fatal error: require_once(): Failed opening required '/home/u327900732/public_html/core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7
我尝试添加“./”的路径,但它仍然无法正常工作。我再说一遍,该网站在我的本地主机上完美运行。请帮助!
试图使用完整的网址来测试你的网址。或者检查您的浏览器以检查文件是否存在。喜欢这里:
http://host.com/core/libs/smarty/Smarty.class.php
我认为它会显示错误,显示你的文件是不存在的存在。
服务器上是否需要(Smarty)文件? – user2182349
如果该文件实际上位于服务器上,那么您可能需要通过其位于服务器上的核心路径进行访问。像'require_once($ _ SERVER ['DOCUMENT_ROOT']。'/ core/libs/smarty/Smarty.class.php');'会工作。你可能需要根据你的目录设计来调整它。 – camelCase
@ user2182349 Smarty文件位于我的主文件夹中,并且我将完整的主文件夹上载到服务器。 – user3891850