我在我的config.php
文件中添加這個define()
函數。php unicode UTF-8導致需要的文件
$options = DataAccess::FETCHLOAD("SELECT sign FROM " . OPTIONS . " WHERE 1");
define('_SIGN_',$options['0']['sign']);
現在,我required
config.php
文件到我的index.php
頁是這樣的:
require $abspath .'/config.php';
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?PHP echo _SIGN_; ?>
</body>
</html>
現在在輸出我有這樣的結果:
?????????????????????
工作結果:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
$options = DataAccess::FETCHLOAD("SELECT sign FROM " . OPTIONS . " WHERE 1");
define('_SIGN_',$options['0']['sign']);
<?PHP echo _SIGN_; ?>
</body>
</html>
輸出結果:
تواصل معنا
如何解決這個作秀的Unicode UTF-8,當我需要config.php
?!
set_charset ("utf8")
我用的MySQLi並使它這樣:
//-> conncecting to db
$mysqli = new mysqli ($hostname, $username, $password, $db);
if ($mysqli -> connect_errno) {
echo 'Failed to connect to MySQL: ' . $mysqli -> connect_error;
}
// change character set to utf8
if (! $mysqli -> set_charset ("utf8")) {
printf ("Error loading character set utf8: %s\n", $mysqli->error);
}
什麼是數據庫中的該表中的字符集? – Machavity 2014-10-28 19:00:22
@Machavity:UTF-8。請參閱我的編輯。 – 2014-10-28 19:15:02
@ o-O你在哪裏設置'$ abspath'? – Rizier123 2014-10-28 21:10:30