tags:

views:

65

answers:

3

I was wondering should the following code listed below display when empty because it does not.

Is this the correct way not to display code when it's empty? If not how should my code look when I don't want the code to be displayed if it's empty? I hope that does not sound confusing?

Here is the code.

<?php
 if(empty($link)){
  echo '<div class="r"><strong>Links: </strong>' . tag_cloud($link) . '</div>';
 }
?>
+3  A: 

Your condition states that if $link is empty, it should be displayed, otherwise not.

Try

if(!empty($link)){
Pekka
But for some reason the code I listed is displayed.
SlapThiS
Probably because $link is empty?
Pekka
+2  A: 

Make sure you trim $link. If $link contains just white space that is NOT considered empty.

aiGuru
Good point.------
Pekka
A: 

I would advise you get into the habit of doing:

var_dump( $link );

whenever you are expecting to test a condition.

Cups