Title: PHP code &quot;jumping&quot; around html
Last modified: August 19, 2016

---

# PHP code "jumping" around html

 *  Resolved [Alejandro Benavente](https://wordpress.org/support/users/bnvt/)
 * (@bnvt)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/php-code-jumping-around-html/)
 * Hi!
    I’m rather new to PHP and WP, and I have recently stumbled upon this odd
   behaviour. It might be some standard in PHP, but I haven’t been able to find 
   any documentation about it.
 * Here it goes. I have this rather simple code:
    `echo "<img src='" . bloginfo('
   template_directory') . "/css/imagenes/p_2.jpg' blabla..."`
 * which, oddly enough, outputs this to html:
    `http://localhost:8888/wp-content/
   themes/Starkers<img src='/css/imagenes/puntuaciones/p_2.jpg' blabla...`
 * As you can see, the code generated by bloginfo() jumps to the beginning of the
   html statement, messing the whole thing up.
    I know I could recode the whole 
   thing as `<img src="<?php echo bloginfo(); ?>" ectcetera>` but I’d rather not
   do it, because it’s located in a php chunck of code which would get quite messy
   if I did.
 * Am I doing anything wrong?
    Thanks a lot.

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

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/php-code-jumping-around-html/#post-1744231)
 * Fix
 *     ```
       echo "<img src='" . get_bloginfo('template_directory') . "/css/imagenes/p_2.jpg' blabla..."
       ```
   
 * You need a return value inside an echo statement, `bloginfo` echoes it’s value(
   so not suited), but `get_bloginfo` gives you a return value, which will work 
   appropriately inside the echo statement.
 *  Thread Starter [Alejandro Benavente](https://wordpress.org/support/users/bnvt/)
 * (@bnvt)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/php-code-jumping-around-html/#post-1744236)
 * Right, that sounds pretty reasonable, Mark. Easy enough 🙂
    Thanks!
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/php-code-jumping-around-html/#post-1744242)
 * You’re welcome… 🙂

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

The topic ‘PHP code "jumping" around html’ is closed to new replies.

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)
 * [jump](https://wordpress.org/support/topic-tag/jump/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/php-code-jumping-around-html/#post-1744242)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
