Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过GET传递变量以决定是否使用UTF-8_Php_Utf 8_Get - Fatal编程技术网

Php 通过GET传递变量以决定是否使用UTF-8

Php 通过GET传递变量以决定是否使用UTF-8,php,utf-8,get,Php,Utf 8,Get,所以我的想法是,如果我使用example.php?u=8,将使用UTF-8。 我以为这样就行了 <?php $u=($_GET["u"]); // 8 is utf8 ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://ww

所以我的想法是,如果我使用example.php?u=8,将使用UTF-8。 我以为这样就行了

<?php
  $u=($_GET["u"]);  // 8 is utf8
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<?php if ($u=8): ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php else: ?>
<?php endif ?>

      <title>just any title</title>
</head>

<body>
</body>
</html>

随便什么头衔都行
显然,我做了一些完全错误的事情,因为它甚至没有给我变量


我哪里出错了?

=
是作业,
=
是比较。如果($u==8),则它应该是
。此外,为了防止关于未定义索引的警告,您应该使用
isset($\u GET['u'])
。谢谢!(我现在觉得有点傻)
=
是作业,
=
是比较。如果($u==8)
,则它应该是
。此外,为了防止关于未定义索引的警告,您应该使用
isset($\u GET['u'])
。谢谢!(我现在觉得有点傻)