7.1k views
0 votes
What are the built-in functions in PHP used to validate user input?

A) getInputValidation()
B) sanitizeInput()
C) filter_input()
D) validateUserInput()

User Lothario
by
7.4k points

1 Answer

3 votes

Final answer:

The correct answer is C) filter_input(). PHP provides several built-in functions that can be used to validate user input. One commonly used function is filter_input().

Step-by-step explanation:

The correct answer is C) filter_input().

PHP provides several built-in functions that can be used to validate user input. One of the most commonly used functions is filter_input(). This function is used to filter user input with a specified filter and returns the filtered data or false if the filtering fails.

For example, to validate a user input as an email address, you can use the following code:

if (filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) {

echo 'Valid email format';

} else {

echo 'Invalid email format';

}

User Jeereddy
by
8.7k points