PHP
  Home arrow PHP arrow Validating URL Protocols, Hosts and Paths with Filters in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Validating URL Protocols, Hosts and Paths with Filters in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2009-08-19


    Table of Contents:
  • Validating URL Protocols, Hosts and Paths with Filters in PHP 5
  • Review: the FILTER_VALIDATE_URL filter
  • Validating URLs more strictly with the FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED constants
  • Validating paths within URLs: the FILTER_FLAG_PATH_REQUIRED argument

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Validating URL Protocols, Hosts and Paths with Filters in PHP 5
    ( Page 1 of 4 )

    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.

    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
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek