Jump to content

Weird conditional behavior


ogarza

Recommended Posts

Hey, been banging my head against the wall for a couple of hours now.

There is an If () in the code that is driving me crazy because it is not behaving like I expect it to..

 

foreach ( $types as $type ) {
    if ( !isset( $type->modclass ) or !isset( $type->typestr ) ) {
        debugging( 'Incorrect activity type in ' . $modname );
        continue;
    }
    $var = (string)$type->type;
    if ( $var != 'assignment&type=online' ) {

        print '<br/>' . $var . '<br/>';
        
        if ( $type->modclass == MOD_CLASS_RESOURCE ) {
            $resources[$type->type] = $type->typestr;
        } else {
            $activities[$type->type] = $type->typestr;
        }
    }
}

 

results in...

 

label

resource&type=text

resource&type=html

resource&type=file

resource&type=directory

resource&type=ims

assignment_group_start

assignment&type=upload

assignment&type=online

assignment&type=uploadsingle

assignment&type=offline

assignment_group_end

 

:wtf:

 

Notice the assignment&type=online in the output... I'm just about ready to give up as to why it is still outputting $var when it is clearly equal to the compared string?

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/209726-weird-conditional-behavior/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.