Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Escape period after php variable inside html attribute.


Reply


2 Posts   2368 Views

Avatar
theoldlr

Community Member, 103 Posts

6 February 2010 at 7:34am

Edited: 06/02/2010 7:36am

In side of a <% control %> I am displaying the languages my site is available in. I wanted to use the flags to represent the languages. I am doing this like so:

<img src="/imagepath/$image.png" />

The '.' interferes with the php variable and the browser sees the code as <img src="/imagepath/" />

the variable $image in this case returns the locales for the languages (i.e. en_US, pt_BR, etc.) so I cannot append .png to the value of variable as this variable is used for other things as well. How do I escape the '.' properly? I have tried $image\.png which ends up returning 'en_US\.png'

thanks in advance!

Avatar
Hamish

Community Member, 712 Posts

6 February 2010 at 6:06pm

Wrap it in curly braces:

<img src="/imagepath/{$image}.png" />