boxturt Posted December 31, 2008 Share Posted December 31, 2008 That's not a good topic title, I apologize. I've always thought that when defining width or height or anything else that anything BUT an absolute number should be wrapped in double quotes. Like width=950 OR width="!00%" . I need to define "100%", "top", "center", etc but of course php says "no, No, NO!" So I have tried: ><? echo "<table width=100% align=center border=0 cellpadding=5 cellspacing=1>\n<tr valign=top align=center>\n"; ?> That works but is it correct? I wonder if that should all be in 'single' quotes (also works) ><? echo "<table width='100%' align='center' border=0 cellpadding=5 cellspacing=1>\n<tr valign='top' align='center'>\n"; ?> Thanks, Happy New Year! Quote Link to comment Share on other sites More sharing options...
Bob Crabb Posted December 31, 2008 Share Posted December 31, 2008 This should work: ><?php echo '<table width="100%" align="center" border="0" cellpadding="5" cellspacing="1">' . "\n" . '<tr valign="top" align="center">' . "\n"; ?> Quote Link to comment Share on other sites More sharing options...
boxturt Posted December 31, 2008 Author Share Posted December 31, 2008 It should and it does. Thank you very much, I appreciate it Quote Link to comment Share on other sites More sharing options...
Bob Crabb Posted January 1, 2009 Share Posted January 1, 2009 It should and it does. Thank you very much, I appreciate it You're welcome. I'm glad that I could help. Quote Link to comment Share on other sites More sharing options...
carbonize Posted February 5, 2009 Share Posted February 5, 2009 (edited) Or of course just escape the quotes like \" ><? echo "<table width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\">\n<tr valign=\"top\" align=\"center\">\n"; ?> But my personal preference is to always use single quotes when possible for PHP strings since it gives a slight speed boost compared to double quotes. This is because PHP scans double quotes strings for variables and special characters (like \n) but with single quotes it only looks for \'. Whilst the speed difference with a single string is negligible imagine outputting a whole scripts worth. This is why Bob's method is preferable. Oh and always wrap your html attributes in double quotes. That is the standard. Edited February 5, 2009 by carbonize 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.