I would create a set of static methods in a class, naming everything so that it's obvious what each method does, e.g.:
<?php
class LengthCoverter
{
const CM_PER_INCH = 2.54;
public static function cmToInches($length)
{
return $length / self::CM_PER_INCH;
}
public static function inchesToCm($length)
{
return $length * self::CM_PER_INCH;
}
}
// Sample usage:
echo "12 inches = ".LengthCoverter::inchesToCm(12)." cm.<br />\n";
echo "7.62 cm = ".LengthCoverter::cmToInches(7.62)." inches.";