frankdm Posted July 23, 2016 Share Posted July 23, 2016 I got the following code: $vargooglelink = "http://www.google.com/search?q="; $varproducttitle = get_the_title(); $varcomplete = $vargooglelink . $varproducttitle; echo $varcomplete; $content .= "<td> <a href=$varcomplete>test</a> </td>"; The echo is just to test, the names in the echo are 100% correct so both variables are filled in as they should. HOWEVER, the $varcomplete only uses the first word of the $varproducttitle in the hyperlink ... again, if i echo &varcomplete or &varproducttitle then in both cases it shows me 100% correct all words.... it is just when I use $varcomplete in the href that it looses any words after the first... I am stumped... I take it has to do with the space between words in &varcomplete (maybe a url doesn't like spaces) but in this case I need those spaces! Quote Link to comment https://forums.phpfreaks.com/topic/301568-strange-variable-problem-space-problem/ Share on other sites More sharing options...
Solution Psycho Posted July 23, 2016 Solution Share Posted July 23, 2016 Parameter values (like the href parameter for an anchor tag) should be within quotes so the browser knows where the value starts and ends. If the value is not within quotes it assumes that the first space is the end of the value $content .= "<td> <a href='$varcomplete'>test</a> </td>"; Quote Link to comment https://forums.phpfreaks.com/topic/301568-strange-variable-problem-space-problem/#findComment-1534925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.