Home arrow PHP arrow Validating URL Protocols, Hosts and Paths with Filters in PHP 5

Validating URL Protocols, Hosts and Paths with Filters in PHP 5

When it comes to checking incoming data in web applications, PHP 5 provides developers with a huge arsenal of functions that permit them to perform this process in a pretty straightforward way. Indeed, checking integers and float numbers, IP and email addresses, alphabetic strings and so forth is a process that must be tackled frequently by programmers. Fortunately, validating data types is not a huge production with PHP.

TABLE OF CONTENTS:
  1. Validating URL Protocols, Hosts and Paths with Filters in PHP 5
  2. Review: the FILTER_VALIDATE_URL filter
  3. Validating URLs more strictly with the FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED constants
  4. Validating paths within URLs: the FILTER_FLAG_PATH_REQUIRED argument
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
August 19, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

PHP 5 comes bundled with a useful set of native filters that allow you to validate all sorts of data types without having to spend a long time coding custom functions. These filters are known popularly as the filter extension and offer a flat learning curve. Therefore, if youíre interested in learning how to get the most out of this extension and want to start using it when developing your own PHP programs, then this series of articles might be what youíre looking for.

Welcome to the sixth part of a series covering the use of filters in PHP 5. Comprised of nine tutorials, this series explores the most relevant filters that come with this handy library, and shows you with practical examples how to use them for checking strings and numeric values, email addresses and URLs, and many other common types of data.

And now that you've been introduced to the main subject of this series, itís time to spend a few minutes reviewing the topics that were discussed in the last installment. In that particular tutorial I explained how to work with regular expressions by using the FILTER_VALIDATE_REGEXP filter in conjunction with the already familiar ďfilter_var()Ē function. Also, I showed how to validate well-formatted URLs at a very basic level by means of another helpful filter, not surprisingly called FILTER_VALIDATE_URL.

As I said, the validation process performed on URLs was pretty simplistic. Thus, in this sixth episode of the series Iím going to dig deeper into the usage of the FILTER_VALIDATE_URL filter to show you how to validate different portions of a URL, including its protocol, host and eventual paths.

So, are you ready to learn how to accomplish all of these useful things with the filter PHP 5 extension? Then letís begin now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: