Title: Widget: cannot compare exact same strings
Last modified: August 21, 2016

---

# Widget: cannot compare exact same strings

 *  Resolved [Snaphaan](https://wordpress.org/support/users/snaphaan/)
 * (@snaphaan)
 * [12 years ago](https://wordpress.org/support/topic/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)

 *  Thread Starter [Snaphaan](https://wordpress.org/support/users/snaphaan/)
 * (@snaphaan)
 * [12 years ago](https://wordpress.org/support/topic/widget-cannot-compare-exact-same-strings/#post-4891194)
 * Apologies for the typo:
    `if(strcmp($textarea, $block) == 0)` should actually
   be: `if(strcmp($textarea, $block) == 1)` as being true.
 *  Thread Starter [Snaphaan](https://wordpress.org/support/users/snaphaan/)
 * (@snaphaan)
 * [12 years ago](https://wordpress.org/support/topic/widget-cannot-compare-exact-same-strings/#post-4891343)
 * Somehow it’s working now. There’s probably some difference on how I store the
   data and what I want to retrieve.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Widget: cannot compare exact same strings’ is closed to new replies.

## Tags

 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 2 replies
 * 1 participant
 * Last reply from: [Snaphaan](https://wordpress.org/support/users/snaphaan/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/widget-cannot-compare-exact-same-strings/#post-4891343)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
