Here's my code.
Code: Select all
$sString = 'television’s';
$_SESSION['badstring'] = $sString;
echo $_SESSION['badstring'];
// Prints televisionÕs
It prints televisionÕs instead of television’s
Any ideas how to solve this?
Moderator: General Moderators
Code: Select all
$sString = 'television’s';
$_SESSION['badstring'] = $sString;
echo $_SESSION['badstring'];
// Prints televisionÕs
Sessions don't encode strings, they simply hold them as entered.parka wrote:It seems like my sessions are not encoding my string properly. I can't seem to remember needing to set the encoding or charset or whatever.
Thanks.Mark Baker wrote:Sessions don't encode strings, they simply hold them as entered.parka wrote:It seems like my sessions are not encoding my string properly. I can't seem to remember needing to set the encoding or charset or whatever.
Try setting the page where you're displaying the value to utf-8
Code: Select all
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?php
$sString = 'television’s';
echo $sString;
?>
</body>
</html>Code: Select all
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
television?s</body>
</html>