【发布时间】:2015-07-18 18:17:47
【问题描述】:
我已经使用 codeigniter 框架创建了一个网站,它在我的本地主机上完美运行,但在 Linux 服务器上无法运行, 我对 baseurl 、 database 、 .htaccess 进行了更改 我已经完美地删除了 index.php ! 但是当我尝试访问我的网址时,日志文件会显示此错误
PHP 解析错误:语法错误,出现意外的 T_FUNCTION /home/httpd/vhosts/Domain.com/httpdocs/application/libraries/format.php 在第 231 行
我尝试制作简单的控制器在调用函数测试时回显“Hello”,
<?php
class test extends CI_Controller {
function __construct() {
parent::__construct();
echo "here";
}
function test(){
echo "Hello inside the function";
}
}
答案是
> here
404 Page Not Found
The page you requested was not found.
没有功能访问:/
但是当我做这个时:
<?php
class test extends CI_Controller {
function test(){
echo "Hello inside the function";
}
}
答案是
Hello inside the function
404 Page Not Found
The page you requested was not found.
有函数访问:3
有人可以帮忙吗??!
顺便说一句,这是我的 .htaccess 代码
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
【问题讨论】:
-
您是否查看了第 231 行的 /home/httpd/vhosts/Domain.com/httpdocs/application/libraries/format.php?这些错误消息是有原因的。
-
是的,没有什么奇怪的
array_walk_recursive($str, function(&$item, $key),我以前多次使用过这个库:/没有任何问题 -
您运行的是什么版本的 PHP?匿名函数是 5.3+。 5.4 之前的任何东西现在都是 EOL。
-
不应该专门针对这种情况,但至少要遵循最低标准:1.) 库文件名应该大写
Format.php, 2.) 类名应该大写class Test extends CI_Controller{}, 3.) 方法应该具有可见性public function test(){}。您将在未来避免潜在的头痛。顺便提一句。使用什么版本的 CI? -
/application/libraries/format.php未与 Code Igniter 2.2 绑定。使用 Code Igniter 2.2 并不意味着每个 3rd 方库都可以与您过时的 PHP 版本一起使用
标签: php linux apache .htaccess codeigniter