Code:
if(isset($i == "logout")) {
}
By order of evaluation this code is asking:
Is the equivalence of $i to "logout" a "set" variable?
The question (immediately above) doesn't make sense. We cannot ask if equivalences are set, we can also ask if they are true or false.
($i=="logout") returns a boolean. That boolean is passed to isset, which expects a variable.
First Evaluation: $i has the same contents as anonymous string "logout"
Possible Returns:
- true
- false
- I don't know, $i is not set
<<< crash
Second Evaluation: has the variable in the isset argument been initialized?
Evaluation:
if $i=="logout" then this evaluates to:
if (isset(true)) {
if $i != "logout" then this evaluates to:
if (isset(false)) {
if $i is not set then this evaluates to:
if (isset(error thrown when comparing empty var to string))
In all three cases we haven't passed isset what it wants, which is an address in memory that either is or is not initialized.
You could replace that with this:
Code:
if (isset($i)) {
if ($i=="logout") {
logout();
}
}