【问题标题】:I have the following error in PHP using XAMPP [duplicate]我在使用 XAMPP 的 PHP 中出现以下错误 [重复]
【发布时间】:2016-11-18 23:43:10
【问题描述】:

我在使用 XAMPP localhost

时出现以下错误

致命错误:无法在第 146 行的 C:\xampp\htdocs\SN\includes\functions\session.php 中重新声明 session_start()

此错误出现在以下代码中:

        /**
 * Session Start
 *
 * @return bool
 */
function session_start(){
    $session_id = '';

    if(SITE_USING_SSL){
        session_set_cookie_params(0, "/", TNB_DOMAIN, true, true);
    }else{
        session_set_cookie_params(0, "/", TNB_DOMAIN);
    }

    // Set Session Handler
    session_set_save_handler('_session_open', '_session_close', '_session_read', '_session_write', '_session_destroy', '_session_gc');

    // Change the default session name
    session_name(SESSION_NAME);

    // Check if session cookie is set and contains only letters and numbers
    if(isset($_COOKIE[SESSION_NAME])){
        if(preg_match('/^[a-zA-Z0-9]+$/', $_COOKIE[SESSION_NAME]) == false){
            $session_data = session_get_cookie_params();
            if(SITE_USING_SSL){
                setcookie(SESSION_NAME, null, time() - 42000, $session_data['path'], $session_data['domain'], true, true);
            }else{
                setcookie(SESSION_NAME, null, time() - 42000, $session_data['path'], $session_data['domain']);
            }
        }else{
            $session_id = $_COOKIE[SESSION_NAME];
        }
    }

    // If a session ID has been passed to the site, use it
    if(not_null($session_id)){
        session_id($session_id);
    }

    // Session Start
    if ($session_start_state != session_start()){
        $session_start_state = session_start();
    }

    // If not present, do not use the current session ID
    if(not_null($session_id)){
        if(!isset($_SESSION['session_start_time'])){
            session_recreate();
        }
    }

    // Server variable for new sessions. Recreate expired sessions.
    if(!isset($_SESSION['session_start_time'])){
        $_SESSION['session_start_time'] = time();
    }else{
        $curr_time = time();
        if($curr_time - $_SESSION['session_start_time'] > SESSION_LIFETIME){
            session_recreate();
            $_SESSION['session_start_time'] = time();
        }
    }

            //THIS IS LINE 146
return $session_start_state;
}

有人知道发生了什么以及如何解决吗?

【问题讨论】:

    标签: php xampp runtime-error declare


    【解决方案1】:

    您需要重命名您的函数,使其不会与 php 预定义的 session_start() 冲突。

    【讨论】:

      猜你喜欢
      • 2019-04-01
      • 1970-01-01
      • 2018-07-06
      • 1970-01-01
      • 2019-03-24
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 2017-12-12
      相关资源
      最近更新 更多