Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

filter_id()

Example

Retrieve the filter ID for the VALIDATE_EMAIL filter.

<?php
echo(filter_id(“validate_email”));
?>

Definition and Usage

The filter_id() function returns the filter ID for a specified filter name.

Syntax

filter_id(filter_name)

Parameter Values

 

Parameter

Description

filter_name

Required. The filter name for which to retrieve the ID. Tip: Use filter_list() to view all available filters.

Technical Details

Return Value:

Returns the filter ID on success, or FALSE if the filter does not exist.

PHP Version:

5.2+

More Examples

Example

In this context, the filter_id() and filter_list() functions are used to list the IDs and names of all available filters.

<table>
  <tr>
    <td>Filter Name</td>
    <td>Filter ID</td>
  </tr>
  <?php
  foreach (filter_list() as $id =>$filter) {
    echo ‘<tr><td>’ . $filter . ‘</td><td>’ . filter_id($filter) . ‘</td></tr>’;
  }
?>

</table>