PHP | Header function not working

|
| By Webner

Code :

Function getredirect($subcontactid)
{
echo”contactid”.$subcontactid;
header("location:https://subscriptions.zoho.com/app#/customers/$subcontactid");
exit;
}

The header function in the above code does not work. But when we remove the echo from the code, it works properly.

Code after removing echo :

Function getredirect($subcontactid)
{
header("location:https://subscriptions.zoho.com/app#/customers/$subcontactid");
exit;
}

The reason is header cannot send headers to the browser if some output (with echo for example) is already sent to the browser.

Leave a Reply

Your email address will not be published. Required fields are marked *