0

I'm trying to build and display a link in PHP with the code:

$displayLink = "<a href={$feed_url}{$feedName} download>$displayFeed</a>"; echo "<br />$displayLink"; 

This works fine, and I'm able to click the link in the HTML and follow it - unless $feedName contains a space. Thus, 'shoes' works but 'our shoes' does not. With $fileName = 'shoes' I get the link:

<a href="http://my_site/users/55/shirts.txt" download="">shoes</a> 

which works fine.

With $fileName = 'our shoes' I get the link

<a href="http://my_site/users/55/shirts.txt" download="">our</a> 

I've tried putting the $feedName variable in single quotes, as below:

$displayLink = "<a href={$feed_url}{'$feedName'} download>$displayFeed</a>"; echo "<br />$displayLink"; 

but that gives me the link:

href="http://my_site/users/55{'/our" shoes.txt'}="" download="">our shoes</a> 

How can I get "our shoes" into the link?

Thanks

1 Answer 1

1

I think this is actually just a problem with how you're constructing the anchor tag. Because you don't add quotes around the href value, a space would signify a break in the tag's value. Your browser would then move on at the space, and in the case of our shirts, shirts would become a new tag.

Just add quotes:

$displayLink = "<a href='{$feed_url}{$feedName}' download>$displayFeed</a>"; 

Example of the comparison: https://eval.in/574053

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.