What are best practices for limiting input length and restricting input to specific characters in PHP?
To limit input length and restrict input to specific characters in PHP, you can use the `substr()` function to limit the input length and `preg_replace()` function with a regular expression to restrict input to specific characters.
// Limit input length to 10 characters
$input = substr($input, 0, 10);
// Restrict input to only alphanumeric characters
$input = preg_replace("/[^a-zA-Z0-9]/", "", $input);