Reputation: 4590
I have an error_codes.php
file located in application/libraries
I have it autoloaded when CodeIgniter loads but the variables are not recognized in the controllers. I get an undefined variable when loading the page. Am I loading the files wrong or do I have the variables wrong. I have tried it wihtout the static
but no luck.
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class error_codes {
static $a200 = array('error' => 'NO', 'code' => '200', 'description' => 'none', 'message' => 'Request ok');
static $a206 = array('error' => 'YES', 'code' => '206', 'description' => 'Partial Content', 'message' => 'Not enough location data!');
//
static $a400 = array('error' => 'YES', 'code' => '400', 'description' => 'Bad Request', 'message' => 'This is not a valid URL');
static $a401 = array('error' => 'YES', 'code' => '401', 'description' => 'Unauthorized', 'message' => 'Did you provide valid API key?');
static $a402 = array('error' => 'YES', 'code' => '402', 'description' => 'Username Exists', 'message' => 'Username already exists!');
static $a403 = array('error' => 'YES', 'code' => '403', 'description' => 'No User Exists', 'message' => 'User does not exists!');
static $a404 = array('error' => 'YES', 'code' => '404', 'description' => 'Invalid Parameters', 'message' => 'Not enough user parameters!');
static $a406 = array('error' => 'YES', 'code' => '406', 'description' => 'Invalid Email', 'message' => 'Email is invalid!');
}
?>
Upvotes: 0
Views: 207
Reputation: 198109
You can not use static variables this way. Convert them to public vars, this might do what you want.
Additionally run your code with a step-debugger and see if your file gets included.
Upvotes: 1