how to display Trademark symbol in php?
I got a trouble regrading of I cannot display trademark symbol? what happen of my code ?
I had test this 2 code in the below, but still failed?
$textmsg = htmlspecialchars($textmsg);
file_put_contents($textpath, $textmsg);
preg_repl开发者_运维问答ace("™", "â„¢Â", $textmsg);
file_put_contents($textpath, $textmsg);
Try using the HTML entity ™
which will display as ™. This applies for HTML and PHP equally. It also gets around issues with text encoding, which is what seems to be the issue for you, though without a bit more information it's hard to say exactly what.
If you are trying to output to a standard text file, then you are going to have to deal with your encoding issues. If this is the case, then you'll need to provide more information as these issues are often difficult to sort out and could even be your text editor and not your code.
Another potentially better solution if you are trying to fix user input is to make sure your server is sending a proper Content-Type
HTTP header, including a text encoding. This will make almost all browsers send data using that encoding, which means it will then be displayed properly when output as well. For instance:
header("Content-Type: text/html; charset=utf-8");
What if you use htmlentities() instead of htmlspecialchars?
精彩评论