自己写的debug类 实现变更输出

<?php

class debug {
  
  /**
    *    在settings.yml中添加如下内容:
    * all:
                 *        .settings:
                 *                        debug:                                on
    */
  
  function __construct() {
    
  //TODO - Insert your code here
  }
  
  /**
    *
    */
  function __destruct() {
    
  //TODO - Insert your code here
  }
  //获取调试开关
  public    function get_debug_sitting() {
    $config=new sfConfig();
    if ($config->get('sf_debug')) {
      return true;
    }else {
      return false;
    }
  }
  //输出调试信息
  //用来输出变量的信息
  public function debug_print($var,$file=__FILE__,$line=__LINE__) {
    if ($this->get_debug_sitting()) {
      $where = "File= $file($line)";
      switch (strtolower(substr(php_sapi_name(),0,3))) {
        case 'cli':
            echo "$where";
            var_dump($var);
            break;        
        default:
            echo "$where";
            print("<pre>");
            var_dump($var);
            print("</pre>");
            break;
      }
      
    }
  }
  
}

?>

你可能感兴趣的:(PHP,debug,Zend,休闲,symfony)