if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) { }else{ document.write('<script async src="//xxx.js"></script>'); document.write('<ins class="adsbygoogle"'); document.write('style="displa...
<?php //php 不同系统的换行 //不同系统之间换行的实现是不一样的 //linux 与unix中用 \n //MAC 用 \r //window 为了体现与linux不同 则是 \r\n //所以在不同平台上 实现方法就不一样 //php 有三种方法来解决 //1、使用str_replace 来替换换行 $str = str_replace(array("\r\n", "\r", "\n"), "", $str); //2、使用正则替换 $str = preg_...
<?php $ip=getClientIp(); $str =$ip.' '.get_iplocation($ip)." JQM22555555 JHM87878844"; write_log($str); /** * 获取客户端IP地址 * * @return NULL | string */ function getClientIp() { $ip = null; if ($ip !== null) { return $ip; } if (isset($_SERVER)) { ...
/** * [write_log 写入日志] * @param [type] $data [写入的数据] * @return [type] [description] */ function write_log($data){ $years = date('Y-m'); //设置路径目录信息 $url = './public/log/txlog/'.$years.'/'.date('Ymd').'_request_log.txt'; $dir_name=dirname($url); //目录不存在就创建 ...
/** * 判断一个数组是否为索引数组 * * @param array $array * @return boolean */ function isIndexArray($array) { $i = 0; $keys = array_keys($array); foreach ($keys as $key) { if (! is_int($key) || $i != $key) { return false; } $i ++; } return true; }
/** * 转换特殊字符为HTML实体字符 * * @param string $string * @param boolean $doubleEncode * @return string */ function htmlEncode($string, $doubleEncode = true) { if (version_compare(PHP_VERSION, '5.4.0', '>=')) { $reVal = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', ...
/** * 获取一个指定长度INT类型HASH值 * * @param string $s * @param number $len * @return number */ function getHash($s, $len = 4) { $h = sprintf('%u', crc32($s)); return intval(fmod($h, $len)); }
/** * 获取文件扩展名 * * @param string $filename * @return string */ function getFileExtName($filename) { $tmp = explode('.', $filename); return $tmp[count($tmp) - 1]; }
/** * 让浏览器下载文件 * * @param string $file 文件路径 * @param string $customName 自定义文件名 * @return string | bool */ function browserDownload($file, $customName = null) { if (file_exists($file)) { $filename = empty($customName) ? basename($file) : $customName; header('Content-lengt...
/** * 获取字符串长度 * * @param string $string * @return int */ function getStringLen($string) { return (strlen($string) + mb_strlen($string, 'UTF8')) / 2; }