PHP | Header function not working

Author - 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.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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