Jump to content
xisto Community
Mordent

Creating Links With Quotes (")

Recommended Posts

While my site's more PHP based than straight HTML, the problem I'm having is with trying to do the following:

 

<a href="page.php?variable=foo "bar" foo">foo "bar" foo</a>
Assuming I have a variable set to foo "bar" foo which I want as both the destination of the link to contain and the actual link itself to look like, how can I make it show as such? Currently, the first quote (just before the first bar) is closing the href element (I believe that's the right word, yes?), meaning the link instead points to 'page.php?variable=foo '. The link is displayed on screen correctly.

 

I tried adding slashes to the variable (page.php?variable=foo \"bar\" foo), but that didn't work at all (it still closes before the bar and now I have slashes to look at in the link). Other than using single quotes instead of double ones, is there a way to escape the double quote character?

 

This problem's most likely ridiculously trivial, I'm probably just having a mind blank (or brain fart, as some people I know call them :) ), so any help would be appreciated.

 

- Mordent

Edited by Mordent (see edit history)

Share this post


Link to post
Share on other sites
<a href="page.php?variable=foo "bar" foo">foo "bar" foo</a>
Just change the outer double quote to single quote would do

<a href='page.php?variable=foo "bar" foo'>foo "bar" foo</a>

I've just tested on firefox3rc1. It should works on other browser as well

Share this post


Link to post
Share on other sites

Other than using single quotes instead of double ones...

:P

 

Anyway, after much tinkering I managed to solve my own problem. The answer was to use " instead of ". As the link was created dynamically, I did this using htmlspecialchars() (using PHP). It prints correctly, and the link points to the right place. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.