ToString

ToString - Casts value to string.

ToString only works with null, bool, int, float, array, any other type is ignored.

Basic usage

use Jawira\Sanitizer\Filters as Sanitizer;

class User {
  #[Sanitizer\ToString]
  public string $name;
}

Parameters

No parameters.

Examples

Cast value to string.

use Jawira\Sanitizer\Filters as Sanitizer;

class Car {
  #[Sanitizer\ToString]
  public $description;
}
null → ""
true → "1"
false → ""
456 → "456"
3.14 → "3.14"

See also

ToInt - Casts value to integer.