Widget: cannot compare exact same strings
-
It seems comparing two exact same strings in the widget display function does not result in true. I have saved the word ‘test’ in the textarea so the code below should result in displaying something like:
correct: test
But it always throws out false which means that the $textarea string value from the widget somehow differs from a normally assigned string.
I’ve tried a normal string comparison as well:
if($textarea == "test")
… and it still results as false.
Any ideas?
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $text = $instance['text']; $textarea = $instance['textarea']; $block = "test"; if(strcmp($textarea, $block) == 0) { echo '<p class="wp_widget_plugin_textarea">correct: '.$textarea.'</p>'; } else { echo 'False'; } echo '</div>'; echo $after_widget; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Widget: cannot compare exact same strings’ is closed to new replies.