# 帝国cms系统提示信息框printerror()函数介绍

*Published:* 2023-10-28
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年10月28日，已超过 180天没有更新



### printerror()函数：

功能：系统提示信息函数，根据传入的参数提示相关信息，并跳转到指定地址。

版本：7.2 7.5

语法：printerror($error,$gotourl,$ecms,$noautourl,$novar)

位置：/e/class/connect.php 200行

函数详细代码：

```
//错误提示
functionprinterror($error="",$gotourl="",$ecms=0,$noautourl=0,$novar=0){
global$empire,$editor,$public_r,$ecms_config;
if($editor==1){$a="../";}
elseif($editor==2){$a="../../";}
elseif($editor==3){$a="../../../";}
else{$a="";}
if($ecms==1||$ecms==9)
{
$a=ECMS_PATH.'e/data/';
}
if(strstr($gotourl,"(")||emptyempty($gotourl))
{
if(strstr($gotourl,"(-2"))
{
$gotourl_js="history.go(-2)";
$gotourl="javascript:history.go(-2)";
}
else
{
$gotourl_js="history.go(-1)";
$gotourl="javascript:history.go(-1)";
}
}
else
{$gotourl_js="self.location.href='$gotourl';";}
if(emptyempty($error))
{$error="DbError";}
if($ecms==9)//前台弹出对话框
{
@include$a.LoadLang("pub/q_message.php");
$error=emptyempty($novar)?$qmessage_r[$error]:$error;
echo"";
db_close();
$empire=null;
exit();
}
elseif($ecms==8)//后台弹出对话框
{
@include$a.LoadLang("pub/message.php");
$error=emptyempty($novar)?$message_r[$error]:$error;
echo"";
db_close();
$empire=null;
exit();
}
elseif($ecms==7)//前台弹出对话框并关闭窗口
{
@include$a.LoadLang("pub/q_message.php");
$error=emptyempty($novar)?$qmessage_r[$error]:$error;
echo"";
db_close();
$empire=null;
exit();
}
elseif($ecms==6)//后台弹出对话框并关闭窗口
{
@include$a.LoadLang("pub/message.php");
$error=emptyempty($novar)?$message_r[$error]:$error;
echo"";
db_close();
$empire=null;
exit();
}
elseif($ecms==0)
{
@include$a.LoadLang("pub/message.php");
$error=emptyempty($novar)?$message_r[$error]:$error;
@include($a."message.php");
}
else
{
@include$a.LoadLang("pub/q_message.php");
$error=emptyempty($novar)?$qmessage_r[$error]:$error;
@include($a."../message/index.php");
}
db_close();
$empire=null;
exit();
}
```

使用说明

$error：提示信息内容，可以为语言包变量，也可以直接提示内容。

$gotourl：提示信息转向链接地址

$ecms：0为后台提示信息、1为前台提示信息、8为后台提示信息(alert方式)、9为前台提示信息(alert方式)

$noautourl：0为自动转向页面，1为不自动转向页面。此参数可省略，默认为0

$novar：0为提示信息内容采用语言包变量，1为提示信息内容为直接提示内容。此参数可以省略，默认为0

使用范例：

```
printerror('DbError','http://www.wdzzz.com',1)，
```

前台提示，提示信息内容为语言包DbError变量内容

附加说明：

此函数需结合$editor变量来确定目录层次。默认$editor变量为0。

当程序文件在/e/path/目录，$editor不用设置，也就是用默认0。

当程序文件在/e/path/path2/目录，$editor=1。

当程序文件在/e/path/path2/path3/目录，$editor=2。

当程序文件在/e/path/path2/path3/path4/目录，$editor=3。