问号php html

时间:2015-12-26 16:34:42

标签: php html utf-8 character-encoding

我有一个html表单,进入php脚本(在php文件中)

表单标题,字段标题等显示得很好但是用户在表单中引入的内容,当它具有“á,é,í,ó,ú”或“ñ”时输出脚本,将这些字符转换为“??”

我已经设置了

<meta charset="utf-8" /> 

header('Content-Type: text/html; charset=utf-8');

涉及表单的所有文件(也是表单中允许的字符),动作网址也有该配置。

但是,我的特殊字符仍会转换为“??”

任何线索?感谢

编辑:文件在utf8中编码也尝试在utf8-without bom

编辑2:

我的表格是:

<form action="file.php" accept-charset="UTF-8" method="post">';
                <label>
                    <span>trailer</span>
                    <input  type="text" name="calidad">
                </label>
                <label>
                    <span>Mediainfo (requerido)</span>
                    <textarea name="mediainfo"></textarea>
                </label>

            <input type="hidden" name="board" id="board" value=' .  $foro . '>

                <label>
                    <span>info</span>
                    <input placeholder="" type="text" name="info" tabindex="3" required>
                </label>

            <input class="botonsubmit" type="submit" value="Postear" name="sub2">
</form>

file.php仅使用

$mediainfo = request_var('mediainfo','');

然后我回应那个变量。

3 个答案:

答案 0 :(得分:0)

保存表单时使用:

utf8_encode($_POST['fieldname'])

显示表单值时:

utf8_decode($_POST['fieldname'])

答案 1 :(得分:0)

您还必须更改apache服务器配置 在httpd.conf中添加(或者如果它已经存在则更改):

AddDefaultCharset utf-8

答案 2 :(得分:-1)

尝试替换这样的特殊字符:

http://www.w3schools.com/charsets/ref_html_ansi.asp

相关问题