What is the purpose of the header() function in PHP?
Correct answer
B. To send raw HTTP headers
14 views
B. To send raw HTTP headers
14 views
The header() function sends a raw HTTP header to the browser. Typical uses are redirects (header("Location: /login.php")), setting the content type, and controlling caching.
It must be called before any HTML or whitespace is output, otherwise PHP reports "headers already sent". It has nothing to do with the HTML <header> element.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.