ogarza Posted August 3, 2010 Share Posted August 3, 2010 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 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? Quote Link to comment https://forums.phpfreaks.com/topic/209726-weird-conditional-behavior/ Share on other sites More sharing options...
Psycho Posted August 3, 2010 Share Posted August 3, 2010 Are you sure there are no leading or trailing spaces or other "white-space" characters? Quote Link to comment https://forums.phpfreaks.com/topic/209726-weird-conditional-behavior/#findComment-1094841 Share on other sites More sharing options...
ogarza Posted August 3, 2010 Author Share Posted August 3, 2010 Are you sure there are no leading or trailing spaces or other "white-space" characters? I tried trim( $var ) as well... could there be some characters missed by trim? Quote Link to comment https://forums.phpfreaks.com/topic/209726-weird-conditional-behavior/#findComment-1094852 Share on other sites More sharing options...
Psycho Posted August 4, 2010 Share Posted August 4, 2010 I would do something like this print '<br/>[' . $var . ']<br/>'; Quote Link to comment https://forums.phpfreaks.com/topic/209726-weird-conditional-behavior/#findComment-1094856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.