What are the potential pitfalls of using multiple header() functions in PHP scripts?

Using multiple header() functions in PHP scripts can lead to conflicts and errors, as each header() call is meant to set a single HTTP header. To avoid issues, you can consolidate all header modifications into a single call by concatenating multiple headers with "\r\n". This way, you ensure that only one header() function is used to set all necessary headers.

<?php
// Consolidating multiple headers into a single call
header("Content-Type: text/html; charset=utf-8\r\nLocation: https://www.example.com\r\n");
exit;
?>