js 根据客户端控制显示广告

js 根据客户端控制显示广告

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...

前端 2020-02-20 AM 2839℃ 0条
php去除换行(回车换行)的三种方法

php去除换行(回车换行)的三种方法

<?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 2020-02-20 AM 1669℃ 0条
php 记录PC电脑软件用户使用记录

php 记录PC电脑软件用户使用记录

<?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)) { ...

PHP 2020-02-20 AM 1725℃ 0条
php write_log 写入日志

php write_log 写入日志

/** * [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); //目录不存在就创建 ...

PHP 2020-02-20 AM 3358℃ 0条
php 判断一个数组是否为索引数组

php 判断一个数组是否为索引数组

/** * 判断一个数组是否为索引数组 * * @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; }

PHP 2020-02-20 AM 1716℃ 0条
php 转换特殊字符为HTML实体字符

php 转换特殊字符为HTML实体字符

/** * 转换特殊字符为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', ...

PHP 2020-02-20 AM 1706℃ 0条
php 获取一个指定长度INT类型HASH值

php 获取一个指定长度INT类型HASH值

/** * 获取一个指定长度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)); }

PHP 2020-02-20 AM 2214℃ 0条
php 获取文件扩展名

php 获取文件扩展名

/** * 获取文件扩展名 * * @param string $filename * @return string */ function getFileExtName($filename) { $tmp = explode('.', $filename); return $tmp[count($tmp) - 1]; }

PHP 2020-02-20 AM 1734℃ 0条
php 让浏览器下载文件

php 让浏览器下载文件

/** * 让浏览器下载文件 * * @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...

PHP 2020-02-20 AM 1569℃ 0条
php 获取字符串长度

php 获取字符串长度

/** * 获取字符串长度 * * @param string $string * @return int */ function getStringLen($string) { return (strlen($string) + mb_strlen($string, 'UTF8')) / 2; }

PHP 2020-02-20 AM 1724℃ 0条
php 校验图片是否有效

php 校验图片是否有效

/** * 校验图片是否有效 * * @param string $file * @return boolean */ function isImage($file) { $tmp = getimagesize($file); switch ($tmp['mime']) { case 'image/jpeg': $img = imagecreatefromjpeg($file); break; case 'image/gif': $img = imagecre...

PHP 2020-02-20 AM 2702℃ 0条