Web Development With PHP
Web Development With PHP - Important Points
11. | Which of the following is NOT a way to prevent SQL injection attacks in PHP? |
---|
A. Use prepared statements
B. Sanitize user input
C. Use mysqli functions instead of mysql functions
D. Allow raw user input in SQL queries
View Answer Discuss Work SpaceAnswer: option d
Explanation:
Allowing raw user input in SQL queries can leave a website vulnerable to SQL injection attacks.
12. | Which PHP function is used to redirect the user to another web page? |
---|
A. header()
B. location()
C. redirect()
D. navigate()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The header() function is used to redirect the user to another web page in PHP.
13. | Which of the following is NOT a valid comparison operator in PHP? |
---|
A. ==
B. !=
C. <=>
D. ><
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The >< characters are not a valid comparison operator in PHP. The <=> operator is used to compare two values and return either -1, 0, or 1 depending on the result of the comparison.
14. | Which PHP function is used to check if a file exists? |
---|
A. file_exists()
B. check_file()
C. exists_file()
D. file_check()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The file_exists() function is used to check if a file exists in PHP.
15. | Which PHP function is used to remove whitespace from the beginning and end of a string? |
---|
A. trim()
B. rtrim()
C. ltrim()
D. strip()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The trim() function is used to remove whitespace from the beginning and end of a string in PHP.