摘要: 匿名函数(Anonymous functions),也叫闭包函数(closures),允许 临时创建一个没有指定名称的函数。最经常用作回调函数(callback)参数的值。当然,也有其它应用的情况。结合array_walk和匿名函数来实现一个结算功能array_walk() 函数对数组中的每个元素应... 阅读全文
posted @ 2015-03-17 18:35 非著名程序师 阅读(451) 评论(0) 推荐(0) 编辑
摘要: 周末梳理了下这段时间看书的一些知识点,进步的过程不仅要实践,还要安排多看书、思考、总结。只针对知识点进行了罗列和简单说明,很多细节还未整理好,待后面再专门详细写。基础易忽略概念PHP是一个支持面向对象开发的语言,而不是一个纯面向对象的语言PHP5中保留了对var的支持,但会将var自动转换为publ... 阅读全文
posted @ 2015-03-10 11:17 非著名程序师 阅读(4044) 评论(0) 推荐(4) 编辑
摘要: 你写了一个PHP脚本,一般都不用考虑内存泄露和垃圾回收的问题,因为一般情况下你的脚本很快就执行完退出了。但在一些运行时间长,数据量大的时候,程序运行一段时间后,php脚本就占用了过多内存,然后就报错(PHP Fatal error: Allowed memory size of 134217728 ... 阅读全文
posted @ 2014-12-25 17:58 非著名程序师 阅读(519) 评论(0) 推荐(0) 编辑
摘要: http_build_query(array$formdata[,string$numeric_prefix] )使用给出的关联(或下标)数组生成一个经过 URL-encode 的请求字符串。参数formdata可以是数组或包含属性的对象。一个formdata数组可以是简单的一维结构,也可以是由数组... 阅读全文
posted @ 2014-12-25 17:37 非著名程序师 阅读(533) 评论(0) 推荐(0) 编辑
摘要: file_get_contents版本: 1 /** 2 * 发送post请求 3 * @param string $url 请求地址 4 * @param array $post_data post键值对数据 5 * @return string 6 */ 7 function send... 阅读全文
posted @ 2014-12-25 17:32 非著名程序师 阅读(4245) 评论(0) 推荐(0) 编辑
摘要: 虽然接触php比较长时间,但有时在使用一些基础东西的时候还会有些不确定,有些疑惑。面向对象涉及到的比较多,大概总结整理一下php的属性、对象,以及访问方式$this $parent self 的使用场景。1. PHP类属性定义和访问方式: 1 tConst; //无错误,无输出 9 ... 阅读全文
posted @ 2014-12-11 18:18 非著名程序师 阅读(2758) 评论(0) 推荐(1) 编辑
摘要: 在PHP中,对于文件的读取时,最快捷的方式莫过于使用一些诸如file、file_get_contents之类的函数,简简单单的几行代码就能 很漂亮的完成我们所需要的功能。但当所操作的文件是一个比较大的文件时,这些函数可能就显的力不从心, 下面将从一个需求入手来说明对于读取大文件时,常用的操作方法。需... 阅读全文
posted @ 2014-12-10 19:18 非著名程序师 阅读(381) 评论(0) 推荐(0) 编辑
摘要: array_flip(array);//传递一个数组参数,对该数组的键、值进行翻转例如:$a = array( 'a', 'b', 'c');print_r(array_flip($a));//输出为:Array( [a] => 0 [b] => 1 [c] =>... 阅读全文
posted @ 2014-12-10 13:50 非著名程序师 阅读(2470) 评论(2) 推荐(2) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2014-10-29 11:44 非著名程序师 阅读(263) 评论(0) 推荐(0) 编辑
摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2014-10-29 11:42 非著名程序师 阅读(2774) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2014-10-29 11:35 非著名程序师 阅读(489) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2014-10-28 23:02 非著名程序师 阅读(560) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2014-10-21 21:53 非著名程序师 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 给定一个二叉树,以集合方式返回其中序/先序方式遍历的所有元素。有两种方法,一种是经典的中序/先序方式的经典递归方式,另一种可以结合栈来实现非递归Given a binary tree, return theinordertraversal of its nodes' values.For examp... 阅读全文
posted @ 2014-10-21 21:44 非著名程序师 阅读(559) 评论(0) 推荐(0) 编辑
摘要: Given two binarytrees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and... 阅读全文
posted @ 2014-10-21 21:37 非著名程序师 阅读(754) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?注意,链表循环并不是尾指针和头指针相同,可能是在中间某一段形成一个环路,所以不能只判... 阅读全文
posted @ 2014-10-21 21:35 非著名程序师 阅读(1175) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321本地注意正负号判断比较关键,实现部分可能不是最优的,按照自己的想法实现:设ret = 1;每次对x进行取余mod,然后ret ... 阅读全文
posted @ 2014-10-21 21:31 非著名程序师 阅读(261) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree,find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest lea... 阅读全文
posted @ 2014-10-21 21:25 非著名程序师 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2014-10-21 21:22 非著名程序师 阅读(432) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2014-10-21 21:07 非著名程序师 阅读(223) 评论(0) 推荐(0) 编辑