$email = "example@example.com"; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "Email is valid"; } else { echo "Email is invalid"; }
$name = $_POST['name']; $name = filter_var($name, FILTER_SANITIZE_STRING);
$number = 123; if (is_numeric($number)) { echo "Number is valid"; } else { echo "Number is invalid"; }This code will output "Number is valid" if the variable is a number, and "Number is invalid" otherwise. Package library: The `is_numeric()` function is a built-in function in PHP, so it does not require any external library or package. In conclusion, PHP has several built-in functions and features to validate and manipulate user input data, and most of them do not require any external library or package.