2016年5月25日
摘要: function changeUrl(base, find, value) { var offset = base.indexOf(find); var index; var rr = ''; if(offset = 0){ rr = right.substr(index); } base = ... 阅读全文
posted @ 2016-05-25 16:26 干锅饭 阅读(187) 评论(0) 推荐(0) 编辑
摘要: function isArray(value) { if (typeof Array.isArray === "function") { return Array.isArray(value); } else { return Object.prototype.toString.call(value) === "[object Array]"; ... 阅读全文
posted @ 2016-05-25 16:21 干锅饭 阅读(305) 评论(0) 推荐(0) 编辑
摘要: <?php function writeFile() { $fp = fopen('test.txt', 'w+'); if (flock($fp, LOCK_EX)) { fwrite($fp, 'Write Someting'); //release file lock flock($fp, LOCK_UN); } else { ... 阅读全文
posted @ 2016-05-25 16:11 干锅饭 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 序列化是将变量转换为可保存或传输的字符串的过程;反序列化就是在适当的时候把这个字符串再转化成原来的变量使用。这两个过程结合起来,可以轻松地存储和传输数据,使程序更具维护性。1. serialize和unserialize函数这两个是序列化和反序列化PHP中数据的常用函数。 当数组值包含如双引号、单引 阅读全文
posted @ 2016-05-25 16:10 干锅饭 阅读(4361) 评论(0) 推荐(0) 编辑
摘要: //Get方式实现 //初始化 $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, "http://www.jb51.net"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //执行并获取HTML文档内容... 阅读全文
posted @ 2016-05-25 16:06 干锅饭 阅读(219) 评论(0) 推荐(0) 编辑
摘要: //Post方式实现 $url = "http://localhost/web_services.php"; $post_data = array ("username" => "bob","key" => "12345"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RET... 阅读全文
posted @ 2016-05-25 16:06 干锅饭 阅读(128) 评论(0) 推荐(0) 编辑
摘要: /** * PHP截取UTF-8字符串,解决半字符问题。 * 英文、数字(半角)为1字节(8位),中文(全角)为2字节 * @return 取出的字符串, 当$len小于等于0时, 会返回整个字符串 * @param $str 源字符串 * $len 左边的子串的长度 */ function utf_substr($str,$len){ for($i=0;$i 127){ ... 阅读全文
posted @ 2016-05-25 16:03 干锅饭 阅读(977) 评论(0) 推荐(0) 编辑
摘要: 在php 中: //GB2312汉字字母数字下划线正则表达式 GBK: preg_match("/^[".chr(0xa1)."-".chr(0xff)."A-Za-z0-9_]+$/",$str); //UTF-8汉字字母数字下划线正则表达式 在php 中: //GB2312汉字字母数字下划线正则 阅读全文
posted @ 2016-05-25 16:00 干锅饭 阅读(5219) 评论(0) 推荐(0) 编辑