PHP htmlentities函数不编码★star

htmlentities($this->name, null, "UTF-8");

Does not encode the star (★). How can I make it encode the star?

Update: &acirc doesn't render a star. Also, I'm using:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

In PHP >= 5.4, the default value of the encoding parameter was changed to UTF-8.

If you use:

htmlentities( "★", null, "ISO-8859-1");

The star character will be converted to &acirc;.

How can I make it encode the star?

You can't. htmlentities does not encode all Unicode characters. But you can try some workarounds, like this one

Or you can make use of output from json_encode:

$txt = preg_replace_callback(
    '/[\x80-\xFF]{3,}/', //do not trust this, it's only example that works for small range of unicode characters, that happens to include black star 
     function($m){ 
         return str_replace('\\u','&#x',trim(json_encode($m[0]),'"')).';';
      }, "Black ★ Star"
); // Black &#x2605; Star