<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Introduction</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="book.filter.html">Filter</a></div> <div class="next" style="text-align: right; float: right;"><a href="filter.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.filter.html">Filter</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="intro.filter" class="preface"> <h1 class="title">Introduction</h1> <p class="para"> This extension filters data by either validating or sanitizing it. This is especially useful when the data source contains unknown (or foreign) data, like user supplied input. For example, this data may come from an HTML form. </p> <p class="para"> There are two main types of filtering: <em class="emphasis">validation</em> and <em class="emphasis">sanitization</em>. </p> <p class="para"> <a href="filter.filters.validate.html" class="link">Validation</a> is used to validate or check if the data meets certain qualifications. For example, passing in <strong><code>FILTER_VALIDATE_EMAIL</code></strong> will determine if the data is a valid email address, but will not change the data itself. </p> <p class="para"> <a href="filter.filters.sanitize.html" class="link">Sanitization</a> will sanitize the data, so it may alter it by removing undesired characters. For example, passing in <strong><code>FILTER_SANITIZE_EMAIL</code></strong> will remove characters that are inappropriate for an email address to contain. That said, it does not validate the data. </p> <p class="para"> <em class="emphasis">Flags</em> are optionally used with both validation and sanitization to tweak behaviour according to need. For example, passing in <strong><code>FILTER_FLAG_PATH_REQUIRED</code></strong> while filtering an <acronym title="Uniform Resource Locator">URL</acronym> will require a path (like <em>/foo</em> in <em>http://example.org/foo</em>) to be present. </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="book.filter.html">Filter</a></div> <div class="next" style="text-align: right; float: right;"><a href="filter.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.filter.html">Filter</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>