<?php

function p($arr)
{
    echo '<pre>';
    print_r($arr);
    echo '<pre>';
}

/*function dump($var, $echo=true, $label=null, $strict=true) {
	$label = ($label === null) ? '' : rtrim($label) . ' ';
	if (!$strict) {
		if (ini_get('html_errors')) {
			$output = print_r($var, true);
			$output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
		} else {
			$output = $label . print_r($var, true);
		}
	} else {
		ob_start();
		var_dump($var);
		$output = ob_get_clean();
		if (!extension_loaded('xdebug')) {
			$output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
			$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
		}
	}
	if ($echo) {
		echo($output);
		return null;
	}else
		return $output;
}*/


//if(!function_exists('f_unit'))
//{
//    function f_unit($str,$unit = null){
//
//        if(empty($str)) return '暂无资料';
//        if($unit != null)
//        {
//            $arr = ['平方米','个','栋','户','年'];
//            foreach ($arr as $val)
//            {
//                if($val == $unit)
//                {
//                    if(strpos($str,$val) !== false)
//                    {
//                        return $str;
//                    }
//                    else
//                    {
//                        return $str.$val;
//                    }
//                }
//
//            }
//        }
//        return $str;
//    }
//}

if(!function_exists('is_mobile'))
{
    function is_mobile()
    {
        if(isset($_SERVER['HTTP_USER_AGENT']))
        {
            $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            $is_pc = (strpos($agent, 'windows nt')) ? true : false;
            $is_mac = (strpos($agent, 'mac os')) ? true : false;
            $is_iphone = (strpos($agent, 'iphone')) ? true : false;
            $is_android = (strpos($agent, 'android')) ? true : false;
            $is_ipad = (strpos($agent, 'ipad')) ? true : false;


//        if($is_pc){
//            return  false;
//        }
//
//        if($is_mac){
//            return  true;
//        }

            if($is_iphone){
                return  true;
            }

            if($is_android){
                return  true;
            }

            if($is_ipad){
                return  true;
            }
        }

    }
}