PHP syntax help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bgbs
Forum Newbie
Posts: 6
Joined: Thu Mar 12, 2009 11:23 am

PHP syntax help needed

Post by bgbs »

Here is the statement I'm having trouble with

Code: Select all

echo '<img src="'. bloginfo('template_directory') .'/images/image.png" title="" alt="" />';
In html source it outputs it like this:

Code: Select all

http://site.com/wp-content/themes/mytheme 
<img alt="" title="" src="/images/image.png">
For some reason it divided the path to image into two parts.
Any ideas what I'm doing wrong?
User avatar
StathisG
Forum Newbie
Posts: 14
Joined: Sat Mar 13, 2010 7:15 pm
Location: UK

Re: PHP syntax help needed

Post by StathisG »

As you can see here, bloginfo echoes the information, where get_bloginfo returns it as a variable. So, your code should be:

Code: Select all

echo '<img src="'. get_bloginfo('template_directory') .'/images/image.png" title="" alt="" />';
bgbs
Forum Newbie
Posts: 6
Joined: Thu Mar 12, 2009 11:23 am

Re: PHP syntax help needed

Post by bgbs »

Oh, you're good.
Thanks man!
User avatar
StathisG
Forum Newbie
Posts: 14
Joined: Sat Mar 13, 2010 7:15 pm
Location: UK

Re: PHP syntax help needed

Post by StathisG »

You're welcome :)
Post Reply