Guest FirefoxRocks Posted August 30, 2009 Share Posted August 30, 2009 Is there any way to simplify this without the use of JavaScript or the get_browser() function in PHP? And by simplifying, I mean the HTML parts of the code, not by combining the echo statements <?php echo '<!--[if !IE]>--><div id="m"><!--<![endif]-->'; echo '<!--[if gte IE 8]><div id="m"><![endif]-->'; echo '<!--[if lte IE 7]><table rules="cols" id="m"><tbody><tr><![endif]-->'; while(condition) { echo '<!--[if !IE]>--><div class="em"><!--<![endif]-->'; echo '<!--[if gte IE 8]><div class="em"><![endif]-->'; echo '<!--[if lte IE 7]><td style="vertical-align: top; text-align: center"><![endif]-->'; // do some stuff echo '<!--[if !IE]>--></div><!--<![endif]-->'; echo '<!--[if gte IE 8]></div><![endif]-->'; echo '<!--[if lte IE 7]></td><![endif]-->'; $i++; } echo '<!--[if !IE]>--></div><!--<![endif]-->'; echo '<!--[if gte IE 8]></div><![endif]-->'; echo '<!--[if lte IE 7]></tr></tbody></table><![endif]-->';?> Link to comment Share on other sites More sharing options...
boen_robot Posted August 30, 2009 Share Posted August 30, 2009 Conditional comments also have & and | as operators for "and" and "or" respectively.Therefore: <?php echo '<!--[if (!IE)|(gte IE 8)]>--><div id="m"><!--<![endif]-->'; echo '<!--[if lte IE 7]><table rules="cols" id="m"><tbody><tr><![endif]-->'; while(condition) { echo '<!--[if (!IE)|(gte IE 8)]>--><div class="em"><!--<![endif]-->'; echo '<!--[if lte IE 7]><td style="vertical-align: top; text-align: center"><![endif]-->'; // do some stuff echo '<!--[if (!IE)|(gte IE 8)]>--></div><!--<![endif]-->'; echo '<!--[if lte IE 7]></td><![endif]-->'; $i++; } echo '<!--[if (!IE)|(gte IE 8)]>--></div><!--<![endif]-->'; echo '<!--[if lte IE 7]></tr></tbody></table><![endif]-->';?> I can't think of a further simplification (other than, as you say, combine the echo statements). Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted September 1, 2009 Share Posted September 1, 2009 That doesn't work in Internet Explorer 7 for some reason it rendered/displayed both the <div> and <table> tags. Link to comment Share on other sites More sharing options...
dsonesuk Posted September 1, 2009 Share Posted September 1, 2009 I mean the HTML parts of the code, not by combining the echo statements<?phpprint<<<END<!--[if (!IE)|(gte IE 8)]>--><div id="m"><!--<![endif]--><!--[if lte IE 7]><table rules="cols" id="m"><tbody><tr><![endif]-->END;while(condition) {print<<<END<!--[if (!IE)|(gte IE 8)]>--><div class="em"><!--<![endif]--><!--[if lte IE 7]><td style="vertical-align: top; text-align: center"><![endif]--> <!--do some stuff--><!--[if (!IE)|(gte IE 8)]>--></div><!--<![endif]--><!--[if lte IE 7]></td><![endif]-->END;i++; } print<<<END<!--[if (!IE)|(gte IE 8)]>--></div><!--<![endif]--><!--[if lte IE 7]></tr></tbody></table><![endif]-->END;?>and i tested this in IE7 (not IE7 within IE8) it worked fine. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.