Jump to content

Any Way To Simplify This?


Guest FirefoxRocks
 Share

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]-->';?>

Edited by FirefoxRocks
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).

Edited by boen_robot
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. Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...