Problem with replacing garbled characters under Mac OS X

WBOY
Release: 2016-07-06 13:52:31
Original
1241 people have browsed it

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>
Copy after login
Copy after login

The screenshot below is allowed, and the garbled code appears.

Problem with replacing garbled characters under Mac OS X

Reply content:

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>
Copy after login
Copy after login

The screenshot below is allowed, and the garbled code appears.

Problem with replacing garbled characters under Mac OS X

Add a line in front header('Content-type: text/html; charset=utf-8'); and try it.

Problem with replacing garbled characters under Mac OS X

Looks like there’s no problem. .

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template