Welcome Guest, Not a member yet? Register   Sign In
Differences in session variable declaration
#1

Hi, I have the following hook

PHP Code:
class LanguageLoader
{
 
 function initialize() {
 
   $ci =& get_instance();
 
   $ci->load->helper('language');

 
   $site_lang $_SESSION['site_lang']; 
 
   //$site_lang = $ci->session->site_lang;
 
   if ($site_lang) {
 
       $ci->lang->load('general'$site_lang);
 
   } else {
 
       $ci->lang->load('general''english');
 
   }
 
 }



With the line
PHP Code:
$site_lang $_SESSION['site_lang']; 
I get the following error

PHP Code:
A PHP Error was encountered
Severity
Notice

Message
Undefined indexsite_lang

Filename
hooks/LanguageLoader.php

Line Number
12

Backtrace
:

FileC:\xampp\htdocs\availability-calendar\application\hooks\LanguageLoader.php
Line
12
Function: _error_handler

File
C:\xampp\htdocs\availability-calendar\index.php
Line
315
Function: require_once 

but replacing it with
PHP Code:
$site_lang $ci->session->site_lang
resolves the problem. I'm curious to know what the issue was though. Thanks.
Reply


Messages In This Thread
Differences in session variable declaration - by n2fole00 - 09-12-2018, 01:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB