porta325 Posted June 18, 2007 Share Posted June 18, 2007 Hey guys, does anyone know how can i make a querry that eventualy will display something like <a href="http://www.somesite.com" target="_blank">anchor</a><br>description. I have a problem with the "" characters. Quote Link to comment https://forums.phpfreaks.com/topic/56081-solved-special-characters-with-echo/ Share on other sites More sharing options...
B34ST Posted June 18, 2007 Share Posted June 18, 2007 you can either escape php ?> or use the ' as follows: <?php echo '<a href="http://www.somesite.com" target="_blank">anchor</a><br>description.'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/56081-solved-special-characters-with-echo/#findComment-276978 Share on other sites More sharing options...
wildteen88 Posted June 18, 2007 Share Posted June 18, 2007 If you are going to be echo'ing out HTML you will need to escape the quotes, eg: <?php echo "<a href=\"http://www.somesite.com\" target=\"_blank\">anchor</a><br>description."; ?> Or you could just use single quotes when defining the string: <?php echo '<a href="http://www.somesite.com" target="_blank">anchor</a><br>description.'; ?> Basically whatever character you use when you start the string (' or ") you must escape that character when you want to use it within the string. If you don't escape your quotes then you'll get errors. You escape the quote by adding a forward slash in front of it as shown above. Quote Link to comment https://forums.phpfreaks.com/topic/56081-solved-special-characters-with-echo/#findComment-276979 Share on other sites More sharing options...
porta325 Posted June 18, 2007 Author Share Posted June 18, 2007 Thanx alot, i didn't knew that. Quote Link to comment https://forums.phpfreaks.com/topic/56081-solved-special-characters-with-echo/#findComment-276991 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.