Why does PHP require such an odd way to specify UTF-8? [duplicate]

  html, php, utf-8

Accented characters weren’t displaying in PHP so I added
header(‘Content-Type: text/html; charset=UTF-8’);
to the header. Still no joy. But I’ve solved it:

<!DOCTYPE html>
<html>
<head>
<?php
header('Content-Type: text/html; charset=UTF-8"');
?>
<meta http-equiv="Content-type" content="text/html" charset=utf-8" / >
</head>
<body>
  Hélène
</body>
</html>

Notice the difference?  Why should a single double quote before the final single quote make all the difference?
If I drop the php making an html file and insert a double quote before utf-8 in the meta tag the way it should be then it doesn't work!
I'm using Chrome Version 88.0.4324.150 (Official Build) (64-bit) - haven't tested with other browsers.

Any ideas?

Source: Ask PHP

LEAVE A COMMENT