Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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 an中特殊字符的问题<;选项>;_Php_Html - Fatal编程技术网

Php an中特殊字符的问题<;选项>;

Php an中特殊字符的问题<;选项>;,php,html,Php,Html,我在数据库的表中保存了一些带有特殊字符的数据(例如ç) 当我需要打印这些数据时,我使用php函数htmlentities,并将其添加到页面标题中 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 一切顺利但是如果我将数据打印到动态菜单的选项中,它将不起作用 代码如下: <select name="group" id="group" style="width:220px">

我在数据库的表中保存了一些带有特殊字符的数据(例如ç

当我需要打印这些数据时,我使用php函数htmlentities,并将其添加到页面标题中

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

一切顺利但是如果我将数据打印到动态菜单的选项中,它将不起作用

代码如下:

<select name="group" id="group" style="width:220px">   
  <option value="0">Choose a Group</option>   
  <?php  
  $ls_groups = ...; // calling function of a class
  foreach ($ls_groups as $dett){
    echo "<option value=" . $dett->id . " " . ($dett->id == $myGroup ? "selected" : "") .  ">" . htmlentities($dett->description,ENT_QUOTES, "UTF-8")  . "</option>";
  }
  ?>  
</select>

选择一组
在哪里可以搜索问题

谢谢

编辑:

这是我仅在选项中打印时使用的

尝试htmlspecialchars()或设置字符集“ISO-8859-1”

参考文献

最后删除并重新创建数据库工作表,因此如果指定的字符集正确,字符集也会出现问题


谢谢大家

你说的“不行”是什么意思?请详细说明出错的地方,并举例说明。此外,请检查您的PHP文件是否采用UTF8编码。如果您使用特殊字符,则会出现常见错误谢谢您的回复,添加了图像!PavelJanicek是的,就说它在任何地方都有效,而不是在选项中!Pete我有两台服务器,php.ini和httpd的配置是相等的,一台可以工作,另一台却什么都没有!知道吗?除了英语,其他语言都是侦探工作。您能演示一下如何调用
$ls\u组
变量吗?可能有问题。如果我将“htmlentities”保存到一个var中,并在它工作后(选项中没有)打印它,那么还要检查$ls_组中的functionno problems。此外,iconv不工作:(所有测试均失败:(