CREATE A DOMAIN AGECHECKER IN PHP
- User
CREATE A DOMAIN AGECHECKER IN PHP
Assistant
Here's a PHP function called
ageCheckerthat validates an age input according to the specified requirements:function ageChecker($age) { // Check if the input is a valid integer if (filter_var($age, FILTER_VALIDATE_INT) === false) { return "Error: Age must be an integer."; } // Convert to integer $age = (int)$age; // Check if age is between 1 and 120 inclusive if ($age < 1 || $age > 120) { return "Error: Age must be between 1 and 120."; } return "Valid age!"; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.