如何使用PHP隐藏正确的代码?

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>';
    }
?>

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

Try

if(!empty($link)){

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

I would advise you get into the habit of doing:

var_dump( $link );

whenever you are expecting to test a condition.