What’ wrong with this syntax?

I am sure this is simple, but I don’t get why…
Why is this wrong?

echo "<img src='".bloginfo('template_directory')."/systemdata/next.png' border=0 id='NavImage'>";

If I do it like this, it works:

Read More
echo "<img src='";
echo bloginfo('template_directory');
echo "/systemdata/next.png' border=0 id='NavImage'>";

What do I do not get? I want to write nice code and the second example is not very elegant I think.

Thanks!

Related posts

Leave a Reply

2 comments

  1. You are using the wrong function, bloginfo() already outputs / echoes so you cannot use it when you want to concatenate strings (nor should you echo it…).

    Instead you could use get_bloginfo() as that returns a string:

    echo "<img src='".get_bloginfo('template_directory')."/systemdata/next.png' border=0 id='NavImage'>";
    
  2. You can try this as far as code elegant factor is concerned:

    $blogingo=bloginfo('template_directory');
    echo "<img src=$blogInfo/systemdata/next.png' border=0 id='NavImage'>";