黄聪

论SEO对人类的重要性,请看我的博客:hcsem.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2012年7月26日

摘要: 上传图片然后按照比例缩略图,指定缩略图的最大高度或者最大宽度。<?php function _UPLOADPIC($upfile, $maxsize, $updir, $newname = 'date') { if ($newname == 'date') $newname = date ( "Ymdhis" ); //使用日期做文件名 $name = $upfile ["name"]; $type = $upfile ["type"]; $size = $upfile ["s... 阅读全文
posted @ 2012-07-26 15:31 黄聪 阅读(23256) 评论(0) 推荐(6) 编辑

摘要: 官方地址:http://sourceforge.net/projects/snoopy/作用:Snoopy is a PHP class that simulates a web browser. It automates the task of retrieving web page content and posting forms, for example.翻译(个人):Snoopy是一个用php写的一个模拟浏览器运行的一个类,他会主动获取网页内容,发送表单等。我最中意的是需要获取一个网页全部链接功能。<? include "Snoopy.class.php"; 阅读全文
posted @ 2012-07-26 15:29 黄聪 阅读(522) 评论(0) 推荐(0) 编辑

摘要: <?php /** 获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址 **/ class GetMacAddr{ var $return_array = array(); // 返回带有MAC地址的字串数组 var $mac_addr; function GetMacAddr($os_type){ sw... 阅读全文
posted @ 2012-07-26 15:27 黄聪 阅读(338) 评论(0) 推荐(0) 编辑

摘要: //Create a variable for start time $time_start = microtime(true); // Place your PHP/HTML/JavaScript/CSS/Etc. Here //Create a variable for end time $time_end = microtime(true); //Subtract the two times to get seconds $time = $time_end - $time_start; ... 阅读全文
posted @ 2012-07-26 15:25 黄聪 阅读(703) 评论(0) 推荐(0) 编辑

摘要: function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength >= 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength >= 2) { $vowels .= "AEUY"; } ... 阅读全文
posted @ 2012-07-26 15:23 黄聪 阅读(325) 评论(0) 推荐(0) 编辑

摘要: 直接上代码function highlight($sString, $aWords) { if (!is_array ($aWords) || emptyempty ($aWords) || !is_string ($sString)) { return false; } $sWords = implode ('|', $aWords); return preg_replace ('@\b('.$sWords.')\b@si', '<strong style="backgr... 阅读全文
posted @ 2012-07-26 15:21 黄聪 阅读(231) 评论(0) 推荐(0) 编辑

摘要: php中时间轴开发,即显示为“刚刚”、“5分钟前”、“昨天10:23”等function tranTime($time) { $rtime = date("m-d H:i",$time); $htime = date("H:i",$time); $time = time() - $time; if ($time < 60) { $str = '刚刚'; } elseif ($time < 60 ... 阅读全文
posted @ 2012-07-26 15:19 黄聪 阅读(368) 评论(0) 推荐(0) 编辑

摘要: 现 在的网页大多采用DIV+CSS设计布局,只要针对移动访问者设计一个专门的CSS,但是移动用户的时候则调用该CSS样式。所以前提是要能够侦测到用户 是否采用移动设备,下面这个函数是PHP判断用户是否用手机访问你的网站,可以判断iphone,Android,Windows Mobile和一般的手机系统,已经能满足这一需求。public function isMobile()public function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGEN 阅读全文
posted @ 2012-07-26 15:15 黄聪 阅读(1893) 评论(0) 推荐(0) 编辑