Chapter 3 of zendframework Learning (Core Component-filter-system predefine filter)

Source: Internet
Author: User

In the filter class of zendframework, the system predefines several common filters, which can be used directly, as shown in the following table:

 

 

Name

Filter content

Name

Filter content

Almum

All content other than letters or numbers

Int

Non-positive content

Alpha

All non-letter content

Realpath

All non-normalized absolute path names

Basename

All non-object names in the specified path

Stringtolower

Convert all letters to lowercase letters

Digits

All non-numeric content

Stringtoupper

Convert all letters to uppercase letters

Dir

All non-directory parts of the given path

Stringtrim

Space at the beginning and end of a string

Htmlentities

Replace the HTML tags "<" and ">"

Striptags

Remove the HTML content of a string

Input

Let's talk about this special story!

 

 

 

Among them, the alpha, stringtolower, and stringtolower filters have been mentioned in the first two sections. I will not talk about them here. Let's focus on the rest.

Alnum letter or value filter

The zend_filter_alnum filter can be used to filter non-numbers, non-letters, and content in the given content. For example, a string "'123! $ # ^ & * $ ABC "is" 123abc "after filtering.

This filter is useful when only letters and numbers are required (such as user names.

Htmlentities HTML Filter

The zend_filter_htmlentities filter can filter the HTML code in the given content. This filter encapsulates htmlentities () in the PHP function, so the HTML content through this filter will be filtered out.

For example, if the string content is "

 

Int integer Filter

The Int filter in the zend_filter filter can perform Integer Conversion on the specified value, that is, filter out the non-integer part. It is very useful for scenarios where the input content is only an integer.

For example, if the content is "23", "5.423", "-4.8", the filtered content is "23", "5", "-4" in turn"

In fact, using intval () in PHP can also achieve this effect.

 

Striptags HTML character Filter

The zend_filter_striptags filter is used to delete the HTML content in the string. This filter is different from the zend_filter_htmlentities filter. zend_filter_htmlentities converts symbols such as "<" and ">. The zend_filter_striptags filter directly filters out the content contained by the "<", ">" and other symbols!

For example, the string after filtering "" Has nothing to do, because it contains no content except the symbols.

<H1> I love Xiaobai.

 

You can try it yourself...

Now, let's get here today ~!

 

A person who has no target will always work for the target person.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.