后端开发|php教程
文件,中文,解决,php,乱码
后端开发-php教程
下面的文件的注释部分含有部分中文,但是乱码了。各位大神,知道该如何把乱码部分解析成中文吗?
<?php
class Database
{
/*****************************************************
** MySQL????????????
*****************************************************/
var $db;
var $seconds;
var $queries;
var $timer= 0;
var $querytimes = array();
var $duration = ”;
圣诞节祝福 源码,vscode清除终端命令行,ubuntu 搭建系统,tomcat包没有安装,爬虫开发ide,php获取视频截图,湖北智能化seo优化方法,贷款网站素材lzw
public $connectData=true;
在线答题 php 源码,装ubuntu时候联网,tomcat8下载与配置,python爬虫解析页面,php云招聘人才系统怎么样,seo锚链接lzw
/*****************************************************
** ??????,?????????
*****************************************************/
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”);
}
}
a站网站源码下载,平板刷ubuntu教程,tomcat8无法访问,识别爬虫流量,php多维数组初始化,企业建设seolzw
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”);
// $query=@fread($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;
}
/*****************************************************
** ?????????
*****************************************************/
function currentTime()
{
list($usec, $sec) = explode(‘ ‘, microtime());
$time = (double)$sec + (double)$usec;
return $time;
}
function show()
{
$message = “\n” . ‘Processed in ‘
. ($this->currentTime() – $this->seconds) . ‘ second(s), ‘
. $this->queries . ‘ queries.’ . “\n”;
// return $this->_textConvert($message);
return $message;
}
/*****************************************************
** ?????????????????????
*****************************************************/
function error($var = false)
{
global $domain,$language,$site_engine_root;
// header(‘Content-Type: text/html; charset=”utf-8″‘);
// @$error = “
“;
if ($GLOBALS[‘sesettings’][‘system’][‘errorreport’]==1)
{
$errorinfo = mysql_errno().”:”.rawurlencode(mysql_error());
$time = date(“Ymd H:i:s”,time());
// @file(“/?domain=$domain&errorinfo=$errorinfo&username=$SESSION[username]&time=$time&language=$language”);
}
if (file_exists($site_engine_root.’data/install.lock’))
{
die($this->_textConvert($error));
}
else
{
die($this->_textConvert($error));
// @header(“Location:/install.php”);
}
// ??????
return $error;
}
/*****************************************************
** ???????sql????
*****************************************************/
function query($sql)
{
global $opendebug,$admincp;
$this->start_timer();
if (($opendebug==1 && $admincp==0) || ($opendebug==2 && $admincp==1))
{
echo ”.$sql.’;
‘;
echo gettotaltime().’
‘;
// echo $sql.’;
‘;
}
$result = @mysql_query($sql, $this->db) or $this->error($sql);
++$this->queries;// ??????????
$this->querytimes[] = $this->stop_timer();
$lowersql=strtolower($sql);
$lowersql=trim($lowersql);
if(substr($lowersql,0,6) == “update” or substr($lowersql,0,6) == “delete” )
{
//echo “find update“;
$affectrows=mysql_affected_rows();
return $affectrows;
}
return $result;
}
/*****************************************************
** ???????sql????
*****************************************************/
function unbufferedQuery($sql)
{
$result = mysql_unbuffered_query($sql, $this->db) or $this->error($sql);
return $result;
}
/*****************************************************
** ????????????????????
*****************************************************/
/*
* $result ??query()????????
* $fetch_mode ????????Ч???
* DB_FETCHMODE_ORDERED (default) ??????????????????
* DB_FETCHMODE_ASSOC???????????????????
* DB_FETCHMODE_OBJECT?????????????
*/
function fetchRow($result, $fetch_mode = false)
{
//assert(‘is_resource($result)’);
switch ($fetch_mode)
{
case DB_FETCHMODE_OBJECT:
$row = @mysql_fetch_object($result);//$row->username
break;
case DB_FETCHMODE_ASSOC:
$row = @mysql_fetch_assoc($result);//$row[‘username’]
break;
case DB_FETCHMODE_ORDERED:
default: // ?????
$row = @mysql_fetch_row($result);// 0,1,2,3
break;
}
return $row;
}
}
?>
回复讨论(解决方案)
显然是你打开的编码与文件的实际编码并不一致。
复制出来的是没办法还原的。你要看原始文件,用正确的编码打开
如果用不正确的编码打开后又保存了,基本上就没办法恢复了。
通过编辑器新建文件 编码设置 utf-8 把你文件复制进去,就不乱码。
3楼你试过?你用的是什么编辑器。我新建了一个txt,然后把它设为UTF-8,再把代码放进去,依然乱码。
把你的原始文件放到云盘上
3楼你试过?你用的是什么编辑器。我新建了一个txt,然后把它设为UTF-8,再把代码放进去,依然乱码。
notepad++ 你试试这个编辑器
1.你这个文件可以在别人给你的时候,就已经是乱码了。
2.文件的存储方改成 UTF8,可以使用UE , EditPlus 都可以,直接另存为,编码选UTF8。
好像不可逆了。