sanitize (function)

Last updated: Tue, Jan 3, 2023 11:15 am
Return to Knowledgebase

Purpose

Sanitizes a string, array or object using the Input class and returns it.

Location

users/helpers/helpers.php

Version Information

First Introduced v3.0.0

Parameters

# Parameter Data Type Required Description
1 $string string, array, or object Yes Early versions of UserSpice can only sanitize strings and other single-level data structures. Modern versions of UserSpice can also sanitize arrays and objects.

Returns

Data Type Description of Returned Data
other Returns a sanitized version of the data passed to it.

Example

$script = sanitize("<script>javascripthere</script>");

Further Documentation:

 Note that depending on your use case, you may need to perform additional sanitization on data keys as you insert them into the database.