natasha_thomas Posted May 21, 2011 Share Posted May 21, 2011 Folks, I want to echo an HTML tag in PHP. <td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);"> So what i am doing is; echo '<td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);">'; And its now working because this tag already has ' (Single Quotes) & ; (Semicolon) so its conflicting. Any work around for this friends? Cheers N Quote Link to comment Share on other sites More sharing options...
matthew9090 Posted May 21, 2011 Share Posted May 21, 2011 put a backslash (\) before every quote like this: echo '<td width=\"300\" bgcolor=\"#ffffff\" align=\"center\" onmouseout=\"style.backgroundColor=\'#ffffff\'\" onmouseover=\"style.backgroundColor=\'#e8e8e8\';\" style=\"word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);\">\'; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 21, 2011 Share Posted May 21, 2011 You only need to escape the single quotes if you are stating the string with a single quote. You don't need to escape the double quotes too! Quote Link to comment 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.