User Tools

Site Tools


web_development:checkmark

Internet Explorer sucks. So here's a way around some of its sucky-ness when you want a checkmark in your document. It's nice and nifty for tables, etc. where you want a bullet list with a bunch of checkmarks, for example.

Usage

Adding this code to your PHP document as-is results in a string called $checkmark containing your checkmark output. To output it, just use any of the following methods within your PHP document:

checkmark.php
<?php
  echo $checkmark;
?>
 
<?= $checkmark ?>
 
<?php
  echo "Here is a checkmark: " . $checkmark;
?>
An Image

You can save this image and place it in /images/ to work with this code.

Source Code:

checkmark_source.php
<?php 
function checkmark() {
  $checkIMG = '/images/Checkmark.png'; // the relative path to your image version of the checkmark
	if (file_exists($checkIMG)) { // the image file exists, so let's use that
	  $checkmark = ' <img src="' . $checkIMG . '"> '; // echo a the checkmark image
	}
	else // the image file does not exist, so let's use html output
	{
	  if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
		$checkmark = ' &radic; '; //
	  }
	  else
	  {
		$checkmark = ' &#x2713; ';
	  }
	}
return $checkmark;
}
$checkmark = checkmark();
?>
web_development/checkmark.txt · Last modified: 2012/02/01 10:39 by garbee