php - 为什么我的 utf8 在我的 php 页面中不起作用?
问题描述
我在这里搜索了很多答案,但 UTF8 仍然存在问题。“特殊”字母没有出现在我的浏览器中。我正在使用:php Designer 8 Wampserver 3.1.4_x86 MySQL 5.6 Navicat100_premium 我正在使用 Google
[ 那些“?” 都是“ççççççççç”
这是代码的开头:
<html>
<title> APPACDM </title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
header('Content-type: text/html; charset=utf-8');
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
解决方案
在我看来,一切都是错误的。如果这是一个嵌入了 PHP 的 HTML 页面,试试这个:
<?php
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title> APPACDM </title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
注意:始终在任何 HTML 输出之前设置您的 PHP 标头响应。始终将 PHP 包装在 PHP 标记中,而不是像您的示例中那样纯文本。
请参见此处:PHP 标头命令
谢谢,
肖恩。
推荐阅读
- c++ - 具有相互引用的 C++ 模板实例化
- javascript - 为屏幕阅读器设置文本并从屏幕阅读器中隐藏孩子
- gulp - postcss/precss - 将 .scss 转换为 .css
- python - 在递归函数调用中收集乘法返回值(自动 nfa 处理)
- java - Elliptic Curve Private Key Length in Java
- html - 网页在 chrome 的检查中响应,但在真实手机上失败
- reactjs - 将常量传递给动作,并使其可发送到后端
- amazon-web-services - Lambda 函数工作,但不能与 API 网关一起工作
- ios - 为什么有响应与无响应的 MTU 不同?
- python - 从重复选择中构造元组