title: Check if a variable is empty
body: <p>I have some user-submitted variables that I want to display in a different part of my site like this:</p>
  
  <pre><code>&lt;div class="pre_box"&gt;Term: &lt;/div&gt;
  &lt;div class="entry"&gt;&lt;?php $key='term'; echo get_post_meta($post-&gt;ID, $key, true); ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Occasionally, these variables might be empty in which case I don't want to display the label for the empty variable. In the example above I would want to hide the <code>&lt;div class="pre_box"&gt;Term: &lt;/div&gt;</code> part. Is there some simple way to check if a php variable like the one above is empty and prevent the label from being displayed?</p>
  
  <p>Update, here is the code using !empty</p>
  
  <pre><code>&lt;?php $key='term' ?&gt;
  &lt;?php if( !empty( $key ) ): ?&gt; 
  &lt;div class="pre_box"&gt;Term: &lt;/div&gt;
  &lt;div class="entry"&gt;
  &lt;?php echo get_post_meta($post-&gt;ID, $key, true); ?&gt;
  &lt;/div&gt; 
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>However, this still displays the content no matter what. I think the problem might be in the way I am defining the $key variable. Im trying to pull data from a custom field set in a wordpress post - thats what the $post->ID business is all about. </p>