To avoid 'headers already sent' error message can I use obstart before session start in PHP, like below:
// db information here
ob_start();
session_start();
Is this a good practice to use in every PHP project to avoid 'header already sent error' or it is for special cases?
Answer
It's not a good practice.
The only correct solution - is to not send anything before you run session.
It's not for special cases, it's for people who cannot write properly. Treat it as a dirty hack for newbies.
No comments:
Post a Comment