php檔案中的中文亂碼該怎麼解決

來源:互聯網
上載者:User
php檔案中的中文亂碼該如何解決
下面的檔案的注釋部分含有部分中文,但是亂碼了。各位大神,知道該如何把亂碼部分解析成中文嗎?
class Database
{
/*****************************************************
** MySQL????????????
*****************************************************/
var $db;
var $seconds;
var $queries;
var $timer = 0;
var $querytimes = array();
var $duration = '';

public $connectData=true;

/*****************************************************
** ??????,?????????
*****************************************************/
function Database($server = '',$username = '',$password = '',$database = '')
{
global $site_engine_root;
// $this->seconds = $this->currentTime();
if ('' == $server)
{
/*****************************************************
** ????????????????
*****************************************************/
$server = $GLOBALS['db_host'];
$username = $GLOBALS['db_user'];
$password = $GLOBALS['db_pass'];
$database = $GLOBALS['db_name'];
}
/*****************************************************
** ?????????
*****************************************************/
if (!$this->db = @mysql_pconnect($server, $username, $password))
{
if ($username == 'root' && $database == 'siteengine')
{
@header("Location:/install.php");
}
else
{
$this->connectData=false;
//$this->error("database connect fail");
}
}
if ($database&&$this->connectData===true)
{
if($this->version() > '4.1')
{
global $config_charset;
$config_charset = 'utf-8';
if(!$dbcharset && in_array(strtolower($config_charset), array('gbk', 'big5', 'utf-8')))
{
$dbcharset = str_replace('-', '', $config_charset);
}
if($dbcharset)
{
mysql_query("SET NAMES '$dbcharset'");
}
}

if($this->version() > '5.0.1')
{
mysql_query("SET sql_mode=''");
}
$this->selectDb($database);
}
return true;
}

/*****************************************************
** ????????????
*****************************************************/
function disconnect()
{
$result = mysql_close() or $this->error();
return $result;
}

/*****************************************************
** ????????
*****************************************************/
function selectDb($database)
{
global $multidomain,$site_engine_root,$tablepre,$db;
if (@mysql_select_db($database, $this->db))
{
return true;
}
else
{
if ($multidomain==1)
{
$query = $this->query("CREATE DATABASE ".$database);
@header("Location:/install.php");
// require $site_engine_root.'lib/query.php';
// $fp = @fopen($site_engine_root.'data/sql/siteengine.sql', "r");
// [email protected]($fp, filesize($site_engine_root.'data/sql/siteengine.sql'));
// @fclose($fp);
// if($tablepre!='boka') $query=str_replace("boka_",$tablepre,$query);
// $sql_query = new query($query);
// $sql_query->doquery();
// @header("Location:/index.php");

}
$this->error("$database database connect error!");
}
}

/*****************************************************
** ???????????Web?????????У????????????????С???Web?????·???true???????????·???false
*****************************************************/
function isWebEnv()
{
if (isset($_SERVER['PHP_SELF']))
{
return true;
}
if (isset($GLOBALS['_SERVER']['PHP_SELF']))
{
return true;
}
return false;
}
/*****************************************************
** ???????????????????
*****************************************************/
function _textConvert($text)
{
if ($this->isWebEnv()) // Web????
{
return nl2br($text);
}
return $text;
}

/*****************************************************
** ?????????
*****************************************************/
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.