Home >Backend Development >PHP Tutorial >Problem with replacing garbled characters under Mac OS X
God, let’s see why the code is garbled?
It hasn’t been solved for several years
Environment: under mac OS I have tested the same problem on both), please help!
<code class="php">$string = "短标题"; $o = preg_replace(array('/\s+/'), array("->"), $string); echo $string , ' ===> ' , $o;</code>
The screenshot below is allowed, and the garbled code appears.
God, let’s see why the code is garbled?
It hasn’t been solved for several years
Environment: under mac OS I have tested the same problem on both), please help!
<code class="php">$string = "短标题"; $o = preg_replace(array('/\s+/'), array("->"), $string); echo $string , ' ===> ' , $o;</code>
The screenshot below is allowed, and the garbled code appears.
Add a line in front header('Content-type: text/html; charset=utf-8');
and try it.
Looks like there’s no problem. .