Join Kevin Skoglund for an in-depth discussion in this video Solution: Convert to and from metric volume, part of Easy PHP Projects: Measurement Conversion.
- In the previous movie, I asked you to try writing…the volume conversion code for yourself.…I hope you got it working.…Let me show you what I came up with,…so you can compare it with your code.…The first thing I did was I worked on…the convert_volume function,…and in order to get that, I took a peek back,…what we did for convert_length.…And here we had convert_to_meters,…convert_from_meters,…and we returned that new_value.…So I want to do the same thing down here.…So I have have convert_to_liters…passing in the value and the from_unit,…and I got back a liter_value.…
Before I called it the meter_value,…but just to be consistent, I called it liters here.…And then I passed in the liter_value with the to_unit…to convert from_liters,…and got back another value, which I then returned.…Easy enough.…Then I went into each one of these functions.…Convert_to_liters takes those two arguments,…the value and the from_unit,…and this code is exactly the same code…that we had up here for convert_to_meters, right here,…except for one change, which is that instead of working…
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
Accessing Databases with Object-Oriented PHPwith 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.