Download the PHP package bayfrontmedia/php-sanitize without Composer
On this page you can find all versions of the php package bayfrontmedia/php-sanitize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/php-sanitize
More information about bayfrontmedia/php-sanitize
Files in bayfrontmedia/php-sanitize
Package php-sanitize
Short Description Simple class used to sanitize, filter and cast data.
License MIT
Homepage https://github.com/bayfrontmedia/php-sanitize
Informations about the package php-sanitize
PHP sanitize
Simple class used to sanitize, filter and cast data.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
Usage
- cast
- url
- path
- escape
cast
Description:
Ensures a given variable will be returned as a specific type. Defaults to "string".
Parameters:
$var
(mixed)$type = self::CAST_STRING
(string): AnyCAST_*
constant
Valid cast types are available as the following constants:
CAST_ARRAY
: arrayCAST_BOOL
: boolCAST_FLOAT
: floatCAST_INT
: intCAST_OBJECT
: objectCAST_STRING
: string
Returns:
- (mixed)
Example:
Description:
Filters string for valid email characters.
Parameters:
$email
(string)
Returns:
- (string)
Example:
url
Description:
Filters string for valid URL characters.
Parameters:
$url
(string)
Returns:
- (string)
Example:
path
Description:
Filters string for valid path syntax, with optional trailing slash.
This method removes any whitespace, spaces, and leading slashes. It will also convert reverse and multiple slashes to one single forward slash.
Parameters:
$path
(string)$trailing = true
(bool): Require trailing slash
Returns:
- (string)
Example:
escape
Description:
Escape strings and arrays. Other data types return their original value.
NOTE: Use caution when escaping entire arrays, as strings should typically only be escaped when outputting to HTML.
See: https://www.php.net/manual/en/mbstring.supported-encodings.php
Parameters:
$value
(mixed)$encoding = 'UTF-8'
(string)
Returns:
- (mixed)
Example: