View Single Post
Old 11-17-2006, 12:20 AM   #11 (permalink)
digiweb
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
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(); } }
digiweb is offline   Reply With Quote