Read Special Character like Register trademark

最后都变了- 提交于 2019-12-13 01:33:05

问题


I use following statement for read the value and its works well.

$PlaceName=$_REQUEST['PlaceName'];

but here is one problem with above statement. If we pass some special type character (like Burger King ®), then variable $PlaceName contains blank value. Note that the reason of this problem is the symbol of registered trademark (®)

So how can I read this type of symbol in PHP by correcting above statement?


回答1:


You can try

header('Content-Type: text/html; charset=utf-8');
$PlaceName= "Burger King ®" ;
echo $PlaceName;



回答2:


It has to do with your encoding, make sure your output is set to utf8.

I just tested this code and output was valid.

<form method="post" action="">
    <input type="text" name="name" />
    <input type="submit" />
</form>

<?php
if ($_POST){
    $name = $_POST['name'];
    echo '<pre>';
    var_dump($_POST);
    echo '</pre>';
    echo '<hr />';
    echo $name;
}


来源:https://stackoverflow.com/questions/12980207/read-special-character-like-register-trademark

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!