gcdb::bail()
最后更新于:2021-11-26 07:52:20
gcdb::bail( string$message, string$error_code=’500′)Wraps errors in a nice header and footer and dies.
参数
- $message
-
(string) (Required) The error message.
- $error_code
-
(string) (Optional) A computer-readable string to identify the error.
Default value: ‘500’
响应
(void|false) Void if the showing of errors is enabled, false if disabled.
源文件
文件: gc-includes/gc-db.php
public function bail( $message, $error_code = '500' ) {
if ( $this->show_errors ) {
$error = '';
if ( $this->use_mysqli ) {
if ( $this->dbh instanceof mysqli ) {
$error = mysqli_error( $this->dbh );
} elseif ( mysqli_connect_errno() ) {
$error = mysqli_connect_error();
}
} else {
if ( is_resource( $this->dbh ) ) {
$error = mysql_error( $this->dbh );
} else {
$error = mysql_error();
}
}
if ( $error ) {
$message = '<p><code>' . $error . "</code></p>n" . $message;
}
gc_die( $message );
} else {
if ( class_exists( 'GC_Error', false ) ) {
$this->error = new GC_Error( $error_code, $message );
} else {
$this->error = $message;
}
return false;
}
}