|
What are the most common PHP filtering functions and techniques?
Changing data type
.
- Force data type to (int)
- Force data type to (float)
- Useful for numeric values, IDs, etc.
strip_tags()
.
- Removes HTML and Javascript tags
- You can "whitelist" allowed tags
str_replace()
.
- Search and replace
- Use to remove undesired characters
- Can use an array as an argument
preg_replace()
.
- Use for intelligent search and replace
- Use "u" modifier to support UTF-8
- Performance considerations involved
- Do not use in a lengthy loop
|
|