How to make the browser recognize utf 8 automatically

  • 2020-12-10 00:39:48
  • OfStack

If you're just starting out with php, you're likely to run into a lot of problems when debugging
Every time I open a browser, I have to change the code, which is a hassle,
Is there a way for the browser to automatically recognize utf-8?
The solution is simply to add a sentence to header

Ex. :

header("Content-type: text/html; charset=utf-8");

'I am a beginner ';

Well, one thing to notice is that
header("Content-type: text/html; charset=utf-8");
You can't print anything to the page before this sentence, meaning you can't use statements like echo, or html tags or text

Related articles: