Join Kevin Skoglund for an in-depth discussion in this video Refactor area conversions, part of Easy PHP Projects: Measurement Conversion.
- In this movie, we'll continue the refactoring work…that we began in the previous movie.…We've refactored the code for length conversion,…now we'll refactor the code for area conversion.…In the last movie, we created functions.php…and we moved some of the functions…from length.php over there.…Let's close up length.php and open up area.php instead.…Now we want to do is the same thing.…We want to take those same functions…that are at the top of area.php and cut them,…save the file, switch over to functions.php…and right below these let's add these new ones in.…
I'll fold those up again just so we can see…a bunch of them at once.…So there we go.…We've got convert_to_meters, convert_from_meters,…convert_length and then…I've got convert_to_square_meters,…convert_from_square_meters, convert_area.…I'll just make a note here in the comments.…This is Area and this is Length.…Okay, so now we want to make the same kinds of changes…that we made to convert to square meters, remember?…We did this.…Let's take that same code and let's just copy it…
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?
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.