【问题标题】:codeigniter stopped working all of suddencodeigniter 突然停止工作
【发布时间】:2015-12-07 11:04:22
【问题描述】:

我有 CodeIgniter 3.0.0,我在 1and1.com 上托管,我使用的是 PHP 5.5。我正在工作的网站曾经在我上次工作时工作。今天,我尝试加载网站,我看到了(我删除了部分路径以不显示我的用户信息):

Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /htdocs/_smchorus/system/core/Common.php on line 238

我认为唯一可能发生变化的是我记得最近在 1and1.com 管理面板上从 php 5.4 迁移到 5.5。我不确定为什么会破坏它。我并没有真正弄乱codeigniter的系统代码。我尝试回到 5.4 并没有解决它。

这一行:

function get_config(Array $replace = array())

第 238 行有问题。

if ( ! function_exists('get_config'))
{
    /**
     * Loads the main config.php file
     *
     * This function lets us grab the config file even if the Config class
     * hasn't been instantiated yet
     *
     * @param   array
     * @return  array
     */
    function get_config(Array $replace = array())
    {
        static $config;

        if (empty($config))
        {
            $file_path = APPPATH.'config/config.php';
            $found = FALSE;
            if (file_exists($file_path))
            {
                $found = TRUE;
                require($file_path);

【问题讨论】:

  • 不确定是否不相关,但您是否更改了您的config 文件? CI 应该适用于 PHP 5.4 及更高版本。
  • 我不知道这会如何工作:function get_config(Array $replace = array())... 是 array,而不是 Array,除非 CodeIgniter 有一个名为 Array 的类。
  • 我猜你的一个配置文件有问题(可能是 config.php 中的拼写错误或类似的东西)配置应该始终是一个数组@这将在 CI 核心中并且可以工作完全没问题...
  • 我只能在 PHP 4.4.9 sandbox.onlinephpfunctions.com/code/…987654321@ 上重新创建这个确切的错误
  • 传递给get_config() 的参数导致错误。仔细检查您的配置文件是否有语法错误。

标签: php codeigniter syntax-error


【解决方案1】:

您可能不小心将您的 php 设置为旧版本。尝试将以下内容添加到您的 index.php 顶部,以检查您是否确实使用了正确的版本。

echo phpversion(); die();

错误似乎不在配置或任何内容中。它说它是一个解析错误,因此关键字Array 一定是导致问题的原因。旧版本的 php 无法识别此语法。因此检查。

【讨论】:

    猜你喜欢
    • 2017-08-22
    • 2021-02-01
    • 2016-12-29
    • 2018-05-09
    • 2015-08-23
    • 2014-02-05
    • 2013-09-06
    • 1970-01-01
    相关资源
    最近更新 更多