Jump to content

Any Way To Simplify This?


Guest FirefoxRocks

Recommended Posts

Guest FirefoxRocks

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...