Title: echo issue with WP function
Last modified: August 22, 2016

---

# echo issue with WP function

 *  Resolved [Amit Biswas](https://wordpress.org/support/users/amitbiswas06/)
 * (@amitbiswas06)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/echo-issue-with-wp-function-help/)
 * Dear friends,
 * I am new WP user and please forgive me for any mistakes when explaining my issue.
 * I am having an issue with “echo”. Here is the situation –
 *     ```
       <?php echo '<p><img src="' . bloginfo('stylesheet_directory') . '/images/img-1.jpg" /></p>' ?>
       ```
   
 * When I am trying this, the output is totally different. The url is displaying
   outside the `<p>` tag.
 * Like this –
 *     ```
       http://127.0.0.1/wp/wp-content/themes/ThemeName<p><img src="/images/img-1.jpg" /></p>
       ```
   
 * But simple use like this – is working great. Why the above is not working? –
 *     ```
       <figure><img src="<?php bloginfo('stylesheet_directory'); ?>/images/img-1.jpg" /></figure>
       ```
   
 * I really don’t know how to fix it. Please help me anyone.
 * Thanks!
    -Amit

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

 *  [Richard Aber](https://wordpress.org/support/users/richaber/)
 * (@richaber)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/echo-issue-with-wp-function-help/#post-5612333)
 * The [bloginfo()](http://codex.wordpress.org/Function_Reference/bloginfo) function
   outputs data directly. In other words, it echoes or prints when you call it.
 * From the bloginfo Codex page :
 * > This always prints a result to the browser. If you need the values for use 
   > in PHP, use get_bloginfo().
 * The [get_bloginfo()](https://codex.wordpress.org/Function_Reference/get_bloginfo)
   function does not echo or print directly, but returns the data for you to manipulate
   or output yourself.
 * It is fairly common in WordPress to have two functions that serve a similar purpose,
   with 1 version that echoes or prints directly, and a corresponding version that
   does not.
 * For your echo statement, you could try something like :
 *     ```
       <?php echo '<p><img src="' . get_bloginfo('stylesheet_directory') . '/images/img-1.jpg" /></p>' ?>
       ```
   
 * However, the [get_stylesheet_directory_uri()](https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri)
   function may be a more appropriate choice.
 *  Thread Starter [Amit Biswas](https://wordpress.org/support/users/amitbiswas06/)
 * (@amitbiswas06)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/echo-issue-with-wp-function-help/#post-5612372)
 * Dear Richard,
 * Thank you so much for your help. I also got same help form stackoverflow.
    As
   I am a new coder, I was doing the php coding in a complex way. like, I was using
   one php block for multiple tasks. So this issue arrived.
 * Now I am doing it is a smarter way and I am using multiple php blocks.
 * -Amit

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

The topic ‘echo issue with WP function’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Amit Biswas](https://wordpress.org/support/users/amitbiswas06/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/echo-issue-with-wp-function-help/#post-5612372)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
