1 | <?php defined('BASEPATH') OR exit('No direct script access allowed'); |
||
3 | class MY_Config extends CI_Config { |
||
4 | 96 | public function __construct() { |
|
7 | /** |
||
8 | * Load Config File |
||
9 | * Tweaked by @DakuTree to allow loading from config/_secure. This is intended to stop duplication of API keys (or other settings) that shouldn't be committed. |
||
10 | * |
||
11 | * @param string $file Configuration file name |
||
12 | * @param bool $use_sections Whether configuration values should be loaded into their own section |
||
13 | * @param bool $fail_gracefully Whether to just return FALSE or display an error message |
||
14 | * @return bool TRUE if the file was loaded correctly or FALSE on failure |
||
15 | */ |
||
16 | 96 | public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) |
|
77 | |||
78 | /** |
||
79 | * Set a config file item by index |
||
80 | * |
||
81 | * @param string $item Config item key |
||
82 | * @param string $value Config item value |
||
83 | * @param string $index Config item index |
||
84 | * @return void |
||
85 | */ |
||
86 | public function set_item_by_index($item, $value, $index) : void { |
||
89 | } |
||
90 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: