Home arrow PHP arrow Validating Boolean Values and Float Numbers with Filters in PHP 5

Validating Boolean Values and Float Numbers with Filters in PHP 5

Welcome to the fourth part of a series covering the use of filters in PHP. In this article, you'll learn some very useful ways to take advantage of the capabilities of the filter extension to validate Boolean values in arrays; we'll also show you how to validate float numbers.

TABLE OF CONTENTS:
  1. Validating Boolean Values and Float Numbers with Filters in PHP 5
  2. Review: the FILTER_VALIDATE_BOOLEAN filter
  3. Validating Boolean values in arrays
  4. Checking for float numbers
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
August 05, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

If you ever thought that PHP 5 comes mostly from its object model, then fortunately I have to say that you're wrong. The latest version of PHP comes packaged with many other handy features that have contributed enormously to making it the mature language that it is nowadays.

However, along with its popular improvements, PHP provides a powerful set of filters for performing all sorts of clever validation on variables. These filters can check integers and float numbers, email addresses and URLs, Boolean values and IPs and much, much more.

This group of filters, also commonly known as "filter extensions," allow you to check for incoming data by using an extremely friendly approach. So if you're searching for a solid library that lets you perform strict validation on user-supplied parameters before doing something useful with them (like inserting them into a database table, for instance), then hopefully this series of articles might be what you need. In it, you'll find a concise guide that will show you how to work with the most useful filters that come bundled with this extension.

And now that you know what to expect from these tutorials, it's time to quickly review the concepts that were covered in the last one. In that specific installment of the series, I discussed the usage of the FILTER_VALIDATE_BOOLEAN filter. As its name suggests, it was used for checking Boolean values in conjunction with the already familiar "filter_var()" function.

In addition, it's fair to note that the aforementioned filter was utilized for determining whether or not the value assigned to a single variable was Boolean. As you learned in previous parts of the series, the filter extension permits you to validate elements of a given array very easily as well. Therefore, in this fourth chapter I'm going to explain how to check for Boolean values in arrays, as well as how to validate float numbers using another handy filter.

Are you ready to continue exploring the numerous capabilities provided by the  PHP 5 filter extension? Then, let's jump in!



 
 
>>> 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: