国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 line
2.1KB

  1. <?php if(!defined('DEDEINC')) exit('dedecms');
  2. /**
  3. * 验证小助手
  4. *
  5. * @version $Id: validate.helper.php 2 13:56 2010年7月5日 tianya $
  6. * @package DedeCMS.Helpers
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. /**
  12. * 浏览器友好的变量输出,便于调试时候使用
  13. *
  14. * @param mixed $var 要输出查看的内容
  15. * @param bool $echo 是否直接输出
  16. * @param string $label 加上说明标签,如果有,这显示"标签名:"这种形式
  17. * @param bool $strict 是否严格过滤
  18. * @return string
  19. */
  20. if ( ! function_exists('Dump'))
  21. {
  22. function Dump($var, $echo=true, $label=null, $strict=true)
  23. {
  24. $label = ($label===null) ? '' : rtrim($label) . ' ';
  25. if(!$strict) {
  26. if (ini_get('html_errors')) {
  27. $output = print_r($var, true);
  28. $output = "<pre>".$label.htmlspecialchars($output,ENT_QUOTES)."</pre>";
  29. } else {
  30. $output = $label . " : " . print_r($var, true);
  31. }
  32. }else {
  33. ob_start();
  34. var_dump($var);
  35. $output = ob_get_clean();
  36. if(!extension_loaded('xdebug')) {
  37. $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
  38. $output = '<pre>'. $label. htmlspecialchars($output, ENT_QUOTES). '</pre>';
  39. }
  40. }
  41. if ($echo) {
  42. echo($output);
  43. return null;
  44. }else
  45. return $output;
  46. }
  47. }
  48. /**
  49. * 获取执行时间
  50. * 例如:$t1 = ExecTime();
  51. * 在一段内容处理之后:
  52. * $t2 = ExecTime();
  53. * 我们可以将2个时间的差值输出:echo $t2-$t1;
  54. *
  55. * @return int
  56. */
  57. if ( ! function_exists('ExecTime'))
  58. {
  59. function ExecTime()
  60. {
  61. $time = explode(" ", microtime());
  62. $usec = (double)$time[0];
  63. $sec = (double)$time[1];
  64. return $sec + $usec;
  65. }
  66. }