Hey there I am trying to create a simple converter for length like cm and m etc, to put onto my simple site that I have started to build, I just don't know how to start it off or what making sure that the code doesnt look like I have copied and pasted it as its for an assignment in uni. I hope someone can help me!!
High Energy Magic Dept.
I would create a set of static methods in a class, naming everything so that it's obvious what each method does, e.g.:
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." ;
Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from
Nation, by Terry Pratchett
"But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html eBookworm.us
Putting it into a form
Originally Posted by
Ok thanks for that, quick question if I was wanting to do it as I wanted to ask the user what value they wanted converted in a form how would I go about doing that?
See the manual page
variables.external to learn how to get data from external sources.
Users Browsing this Thread
There are currently 1 users browsing this thread.
(0 members and 1 guests)