⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class_exception.php

📁 一个基于web的rpg游戏源代码
💻 PHP
字号:
<?php/*** Netlands World Server is the coordinator of the VR in the Netlands Project* Copyright (C) 2002 Ricard Pillosu* * This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* of the License, or (at your option) any later version.* * This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.* * You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*//*** Standard class for exceptions.** @version $Id: class_exception.php,v 1.1 2002/09/25 17:30:12 antoniob Exp $* @author Ricard Pillosu <ricardpillosu@dorna.com>* @copyright Ricard Pillosu 2002* @since Fri, 06 Sep 2002 16:51:06 +0200*/class exception {    /**    * @var string    */    private $error_msg;    /**    * @var string    */    private $error_function;    /**    * @var string    */    private $error_class;    /**    * @var string    */    private $error_file;    /**    * @var integer    */    private $error_line;    /**    * @var array    */    private $other_info;    function __construct($error='', $backtrace='') {        // Get error message (most basic)        if(empty($error)) {            $error = "Unknown exception";        }        $this->error_msg = $error;            // Get backtrace information (most complete)        if(is_array($backtrace)) {            foreach($backtrace as $trace) {                if(isset($trace['class'])) {                    $this->error_class[] = $trace['class'];                }                $this->error_function[] = $trace['function'];                $this->error_line[] = $trace['line'];                $this->error_file[] = $trace['file'];            }        }        // Get all other information we could print (normally bad var values)        $this->other_info = array();        if(func_num_args() > 2) {            $other_args = func_get_args();            array_shift($other_args);            array_shift($other_args);            $this->other_info[] = $other_args;        }    }    function get_msg()    {        return($this->error_msg);        }    function get_all()     {        $msg = "MESSAGE: ".$this->error_msg."\n";        for($i=0; $i<count($this->error_function); $i++) {            if(isset($this->error_class[$i])) {                $class = $this->error_class[$i].'::';            } else {                $class= '';            }            if($i > 0) {                $c = "< ";            } else {                $c = '';            }            $file = basename($this->error_file[$i]);            $msg.= sprintf(" %s%s%s [%s:%s]\n",                 $c,                $class,                $this->error_function[$i],                $file,                $this->error_line[$i]);        }        foreach($this->other_info as $info) {            $msg.= " (".$this->svar_dump($info).")";        }        return($msg);    }    /**    * like var_dump but returns result    *    * @var  mixed    */    function svar_dump($var)    {        ob_start();        var_dump($var);        $result = ob_get_contents();        ob_end_clean();        return($result);    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -