Join Kevin Skoglund for an in-depth discussion in this video Convert to metric length, part of Easy PHP Projects: Measurement Conversion.
- In this movie, we'll plan out how…we'll perform our conversions in PHP.…There are two fundamental approaches…that we could take to performing these conversions.…Approach one is that we could maintain…formulas to convert from each unit…to every other possible unit.…So if we wanted to have miles converted into kilometers,…we'd need to have a formula for that.…From miles to yards, we'd have another formula for that.…From miles to meters, we'd have another one there.…The nice thing about this approach is that we can…perform that conversion in a single calculation.…
However, it means maintaining a lot of formulas,…and it gets worse as we add more length options.…If we have ten length types, the number of formulas…required to convert between any two units would be…nine plus eight, plus seven, plus six, plus five,…plus four, plus three, plus two, plus one.…That's a total of 45 possible formulas.…If we wanted to added support for…one more unit of conversion in the future,…then we'd have to add ten more formulas…for converting that new unit into each and every one…
Along the way, series designer Kevin Skoglund introduces coding strategies, refactoring techniques, and useful skills including dynamically generating form select-option values and formatting decimal numbers and scientific notation.
- Converting length and area measurements
- Using functions to avoid repetition
- Refactoring to produce simpler code
- Converting volume and mass
- Generating form select-option values dynamically
- Formatting scientific notation
- Converting speed and temperature
Skill Level Beginner
PHP: Accessing Databases with PDO and MySQLiwith David Powers3h 47m Intermediate
1. Length and Distance
3. Volume and Capacity
4. Mass and Weight
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.