Title: php echo not working correctly with multiple statements&#8230;
Last modified: August 20, 2016

---

# php echo not working correctly with multiple statements…

 *  [abductedrecords](https://wordpress.org/support/users/abductedrecords/)
 * (@abductedrecords)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/php-echo-not-working-correctly-with-multiple-statements/)
 *     ```
       <?php if(get_post_meta($post->ID, "website", true)=='website');{
       							echo get_post_meta($post->ID, "website", true); }?>            
   
       						<?php if(get_post_meta($post->ID, "website", true)=='website'); {
       							echo '<a href="' . get_post_meta($post->ID, "website", true) . '">TESTLINK</a> •'; }?>
       ```
   
 * Above i have 2 lines of code. Im trying to only display a link for a website 
   when there is a website defined by the user. For some reason the secodn statement
   shows “TESTLINK” on every post, when the first one only displays the text of 
   the website when there is one, and nothing when there isnt (which is what i want).
   Why does the 2nd code echo every time no matter what? thanks ahead of time for
   the help

Viewing 1 replies (of 1 total)

 *  [bcwp](https://wordpress.org/support/users/bcwp/)
 * (@bcwp)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/php-echo-not-working-correctly-with-multiple-statements/#post-2351997)
 * Remove the ; before the { on both if statement lines. The format for if statements
   in PHP is:
 *     ```
       <?php if ( $value == $variable ) { ?>
       <?php echo 'the condition was true'; ?>
       <?php else { ?>
       <?php echo 'the condition was false'; ?>
       <?php } ?>
       ```
   
 * or, you can use : and endif; instead of curly braces {}, like so
 *     ```
       <?php if ( $value == $variable ) : ?>
       <?php echo 'the condition was true'; ?>
       <?php else : ?>
       <?php echo 'the condition was false'; ?>
       <?php endif; ?>
       ?>
       ```
   
 * Of course, you don’t need to break in and out of <?php ?> code blocks on every
   line. I only did that for example purposes.
 * Just don’t mix and match the formats, and don’t place a semicolon ; at the end
   of an if statement because it is not a function call.

Viewing 1 replies (of 1 total)

The topic ‘php echo not working correctly with multiple statements…’ is closed to
new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcwp](https://wordpress.org/support/users/bcwp/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/php-echo-not-working-correctly-with-multiple-statements/#post-2351997)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
