
php
文章平均质量分 55
ps_小飞
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
javascript调用php文件
在b.php中有这样一段PHP代码:echo "document.write(88)";?>原创 2016-05-10 18:29:59 · 1083 阅读 · 0 评论 -
php 随机取数组中的一个值,或多个值
function rand_one($numone = array()){$len = sizeof($numone,1);$j = rand(0,$len-1); return $numone[$j]; }function rand_num($num = array(),$sj = 5){$myWant = array();for($i=0;$i原创 2016-05-20 16:14:58 · 2994 阅读 · 0 评论 -
php 生成随机密码的几种方法
使用PHP开发应用程序,尤其是网站程序,常常需要生成随机密码,如用户注册生成随机密码,用户重置密码也需要生成一个随机的密码。随机密码也就是一串固定长度的字符串,这里我收集整理了几种生成随机字符串的方法,以供大家参考。方法一: 1、在 33 – 126 中生成一个随机整数,如 35, 2、将 35 转换成对应的ASCII码字符,如 35 对应 # 3、转载 2016-05-20 16:16:23 · 590 阅读 · 0 评论 -
php 查看代码执行时间
时间效率对比 1234567891011121314151617181920function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((floa转载 2016-05-20 16:35:19 · 5453 阅读 · 0 评论 -
php 在原有xml文件中追加节点
$xmlpatch = 'index.xml';$doc = new DOMDocument(); $doc -> formatOutput = true; if($doc -> load($xmlpatch)) { $document = $doc -> documentElement;//获得根节点(root) for($i=1;$i$item=$doc原创 2016-05-20 17:48:38 · 2213 阅读 · 0 评论 -
php xml删除节点
$xmlpatch = 'index.xml';$_id = '2';$doc = new DOMDocument();$doc -> formatOutput = true;if($doc -> load($xmlpatch)) {$document = $doc -> documentElement;$elm = $document -> getElementsByTa原创 2016-05-20 18:17:23 · 892 阅读 · 0 评论 -
php xml修改节点中的属性和值
$xmlpatch = 'index.xml';$doc = new DOMDocument();$doc -> formatOutput = true;if($doc -> load($xmlpatch)) {$document = $doc -> documentElement;$elm = $document -> getElementsByTagName原创 2016-05-20 18:09:36 · 2571 阅读 · 0 评论 -
php 创建xml文件
$xmlpatch = 'index.xml';$doc=new DOMDocument("1.0","utf-8");$doc->formatOutput=true; $document=$doc->createElement("document");$document=$doc->appendChild($document);$d原创 2016-05-20 17:41:20 · 464 阅读 · 0 评论 -
php 下载网络图片到本地服务器
$url = "http://res.kumi.cn/templates/kumi/file/2016xiyouji/img/3.png";//$filename = '1.png';function GetImage($url, $filename = "") {if ($url == "") {return false;}if ($filename == "") {原创 2016-05-20 18:40:09 · 1632 阅读 · 0 评论 -
php 类中调用另一个类
require_once("mysqli.php");$db = new db_mysqli();class PayService{public $db; public function __construct(){$this->db = $GLOBALS['db'];}//随机生成站内测试订单号public function getOr原创 2016-07-05 11:44:38 · 11150 阅读 · 0 评论 -
php 生成xls文件utf8转gbk丢失内容的解决方法
iconv('utf-8', 'gbk', $data); 改为:iconv('utf-8', 'gbk//IGNORE', $data);原创 2016-08-16 09:32:18 · 870 阅读 · 0 评论 -
php 设置cookie函数setcookie详解
bool setcookie(string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]])bool setcookie(string name,string value原创 2016-08-09 13:43:21 · 10156 阅读 · 0 评论 -
php cookie删除
设置 失效时间$endtime = time()-1;setcookie('name','',$endtime);print_r($_COOKIE);原创 2016-08-09 16:34:06 · 303 阅读 · 0 评论 -
php 时间相差(x年前,x月前,x天前,x小时前,x分钟前,x秒前)
function timeDiff($time){$timeCurrent=time();$timeDiff=abs($timeCurrent-$time);//取时间差的绝对值$second=floor($timeDiff);//相差秒数$minite=floor($timeDiff/60);//相差分钟数$hour=floor($timeDiff/3600);//相差小时数翻译 2016-05-20 16:12:34 · 442 阅读 · 0 评论 -
php 时间秒数转换成H:i:s
function changeTimeType($seconds){if ($seconds>3600){$hours = intval($seconds/3600);$minutes = $seconds-3600*$hours;$time = $hours.":".gmstrftime('%M:%S', $minutes);}else{$time = gmstrftim原创 2016-05-20 16:00:14 · 494 阅读 · 0 评论 -
生成json数据
//生成json数据function make_json_app_response($error = 0, $content='app'){ include_once('cls_json.php'); $json = new JSON; $time = time();if ($error==1)$res = array('code' => $e原创 2016-04-22 09:34:31 · 892 阅读 · 0 评论 -
$.getJson跨域取数据
$.getJSON("http://domain/mama/dianzan.php?action=cli&siteid=3&id="+cid+"&jsoncallback=?",function(data){if(data.status==1){location.reload();}else{ return false; } });dianz原创 2016-05-11 14:30:11 · 444 阅读 · 0 评论 -
php获取网址url的状态
function http_status($url){$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_NOBODY, 1);curl_setopt($ch, CURLOPT_RETURNTRANSF原创 2016-05-16 16:28:06 · 864 阅读 · 0 评论 -
php curl获取到json对象并转成数组array
例子:function objtoarr($obj){$ret = array();foreach($obj as $key =>$value){if(gettype($value) == 'array' || gettype($value) == 'object'){$ret[$key] = objtoarr($value);}else{$ret[$key] = $v原创 2016-05-16 16:34:24 · 9488 阅读 · 0 评论 -
php 删除目录及目录下文件
//删除目录及目录下文件function deldir($path){ //给定的目录不是一个文件夹 if(!is_dir($path)){ return null; } $fh = opendir($path); while(($row = readdir($fh)) !== false){ //过滤掉虚拟原创 2016-05-17 10:19:42 · 1055 阅读 · 0 评论 -
php 递归创建目录
function recursive_mkdir($created_path, $before_path, $mode = 0777) { $dirs = explode('/' , $created_path); $count = count($dirs); for ($i = 0; $i if (empty($dirs[$i])) co翻译 2016-05-17 10:21:20 · 394 阅读 · 0 评论 -
php 递归创建及删除目录
//递归创建目录function recursive_mkdir($created_path, $before_path, $mode = 0777) { $dirs = explode('/' , $created_path); $count = count($dirs); for ($i = 0; $i if (empty($dir翻译 2016-05-17 10:22:49 · 362 阅读 · 0 评论 -
php 利用远程jpg图片创建新jpg图片
//利用远程图片创建新图片翻译 2016-05-17 11:18:41 · 633 阅读 · 0 评论 -
php getimagesize获取图片信息(.jpg,.gif,.png)
/*.jpg .jpegarray (size=7) 0 => int 120 1 => int 90 2 => int 2 3 => string 'width="120" height="90"' (length=23) 'bits' => int 8 'channels' => int 3 'mime' => string 'image/原创 2016-05-17 11:24:00 · 1297 阅读 · 0 评论 -
php 利用远程图片创建新图片(jpg,gif,png)
function resizejpg($imgsrc,$imgwidth,$imgheight,$filepath){$arr = getimagesize($imgsrc);$imgWidth = $imgwidth;$imgHeight = $imgheight;if($arr[2]==1){$imgsrc = imagecreatefromgif($imgsrc);原创 2016-05-17 11:27:52 · 552 阅读 · 0 评论 -
php 利用远程gif图片创建新gif图片
//利用远程gif图片创建新gif图片function resizejpg($imgsrc,$imgwidth,$imgheight,$filepath){$arr = getimagesize($imgsrc);$imgWidth = $imgwidth;$imgHeight = $imgheight;$imgsrc = imagecreatefromgif($imgsr原创 2016-05-17 11:31:11 · 336 阅读 · 0 评论 -
php 利用远程png图片创建新png图片
利用远程png图片创建新png图片function resizepng($imgsrc,$imgwidth,$imgheight,$filepath){$arr = getimagesize($imgsrc);$imgWidth = $imgwidth;$imgHeight = $imgheight;$imgsrc = imagecreatefrompng($imgsr原创 2016-05-17 11:33:55 · 313 阅读 · 0 评论 -
php 利用远程图片创建新图片完善(jpg,png,gif)
function resizeimage($imgsrc,$imgwidth,$imgheight,$filepath){$arr = getimagesize($imgsrc);$imgWidth = $imgwidth;$imgHeight = $imgheight;$mime = explode('/',$arr['mime']);$ext = $mime[1];原创 2016-05-17 11:38:11 · 381 阅读 · 0 评论 -
php cookie用法
cookie和session都可以暂时保存在多个页面中使用的变量,但是它们有本质的差别。cookie存放在客户端浏览器中,session保存在服务器上。它们之间的联系是session ID一般保存在cookie中。cookie工作原理当客户访问某个网站时,在PHP中可以使用setcookie函数生成一个cookie,系统经处理把这个cookie发送到客户端并保存在c:Doc转载 2016-08-09 16:36:50 · 319 阅读 · 0 评论