bootstrap.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. function p($arr)
  3. {
  4. echo '<pre>';
  5. print_r($arr);
  6. echo '<pre>';
  7. }
  8. /*function dump($var, $echo=true, $label=null, $strict=true) {
  9. $label = ($label === null) ? '' : rtrim($label) . ' ';
  10. if (!$strict) {
  11. if (ini_get('html_errors')) {
  12. $output = print_r($var, true);
  13. $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
  14. } else {
  15. $output = $label . print_r($var, true);
  16. }
  17. } else {
  18. ob_start();
  19. var_dump($var);
  20. $output = ob_get_clean();
  21. if (!extension_loaded('xdebug')) {
  22. $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
  23. $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
  24. }
  25. }
  26. if ($echo) {
  27. echo($output);
  28. return null;
  29. }else
  30. return $output;
  31. }*/
  32. //if(!function_exists('f_unit'))
  33. //{
  34. // function f_unit($str,$unit = null){
  35. //
  36. // if(empty($str)) return '暂无资料';
  37. // if($unit != null)
  38. // {
  39. // $arr = ['平方米','个','栋','户','年'];
  40. // foreach ($arr as $val)
  41. // {
  42. // if($val == $unit)
  43. // {
  44. // if(strpos($str,$val) !== false)
  45. // {
  46. // return $str;
  47. // }
  48. // else
  49. // {
  50. // return $str.$val;
  51. // }
  52. // }
  53. //
  54. // }
  55. // }
  56. // return $str;
  57. // }
  58. //}
  59. if(!function_exists('is_mobile'))
  60. {
  61. function is_mobile()
  62. {
  63. if(isset($_SERVER['HTTP_USER_AGENT']))
  64. {
  65. $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
  66. $is_pc = (strpos($agent, 'windows nt')) ? true : false;
  67. $is_mac = (strpos($agent, 'mac os')) ? true : false;
  68. $is_iphone = (strpos($agent, 'iphone')) ? true : false;
  69. $is_android = (strpos($agent, 'android')) ? true : false;
  70. $is_ipad = (strpos($agent, 'ipad')) ? true : false;
  71. // if($is_pc){
  72. // return false;
  73. // }
  74. //
  75. // if($is_mac){
  76. // return true;
  77. // }
  78. if($is_iphone){
  79. return true;
  80. }
  81. if($is_android){
  82. return true;
  83. }
  84. if($is_ipad){
  85. return true;
  86. }
  87. }
  88. }
  89. }