Join Kevin Skoglund for an in-depth discussion in this video Validate an IP address, part of Easy PHP Projects: Single-Serving Sites.
- In this movie, we'll make one additional improvement…to our single serve website to detect IP addresses.…Let's ensure that the IP address that we return…at least appears to be a legitimate IP address.…We can't know if it actually exists,…but we can tell if it has a recognizable format.…And we can do that using PHP.…Starting with PHP 5.2, we can use the built-in function…filter_var to accomplish this task.…It's filter underscore var, then you pass in…the value that you want to filter,…the filter that you want to use,…and any options.…
Now this is a general filtering function.…It's not just for filtering to validate IP addresses.…But we can pass in the flag that lets it know…we want to filter an IP address into that second argument…where it says filter.…And it's going to return the filter data…or false if it fails.…So if we use it for filtering IP addresses…it looks like this.…Filter_var, you pass in the possible IP address,…we tell it we want to use the filter validate_IP,…and then any options we want to use.…
- Finding and validating an IP address with PHP
- Parsing the HTTP request for browser details
- Comparing dates and times in PHP
- Randomizing data with PHP
- Styling page content dynamically
- Generating random sentences
Skill Level Beginner
1. What is My IP Address?
2. Browser Mirror
3. Is it New Years Yet?
4. Random Data and Styling
5. Random Phrase Generator
- 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.