![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
php
安安兮
这个作者很懒,什么都没留下…
展开
-
PHP实现圆角图片
工作中用到,自己写了一个,分享给有需要的人,前面是类定义,后面2行是调用。 优点:不需要外部图片支持PNG透明可自定义圆角半径 不足:只能指定一种透明色 <?phpclass RoundedCorner { private $_r; private $_g; private $_b; private $_image_p原创 2009-11-05 09:54:00 · 2821 阅读 · 3 评论 -
PHP实现简单Diff
<br /><?php /** * Simple diff imlementation * Test example from http://en.wikipedia.org/wiki/Diff */ $orginal = "This part of the document has stayed the same from version to version. It shouldn't be shown if it doesn't change. Otherwise, th原创 2011-04-06 15:35:00 · 1140 阅读 · 0 评论 -
BST树和RBT树
parent = NilNode::getInstance(); $this->left = NilNode::getInstance(); $this->right = NilNode::getInstance(); } static public function isNil(Node $node) { return is_a($node, 'NilNode'); } } class NilNode extends Node{ static protecte原创 2011-03-21 11:53:00 · 433 阅读 · 0 评论 -
数羊啦
<br />有一种羊,寿命为5年,其中第2年,第4年,都会生一只小羊,现在农场里搞来一头这样的羊,请问n年后,该农场有几头羊呢?<br /> <br />function count_sheep($year) { $year = (int)$year; if ($year < 1) $year = 1; if ($year == 1) return 1; $sheep[1] = 1; $sheep[2] = $sheep[3] = $sheep[4] = $sheep[5] = 0;原创 2011-03-13 02:43:00 · 354 阅读 · 0 评论 -
PHP实现MaxHeap
<br />从PHP5.3开始,PHP已经内置了MaxHeap的结构,见http://cn.php.net/manual/en/class.splmaxheap.php<br /> <br />以下纯属无聊:<br /> <br /><?php class MaxHeap { protected $_data = array(); protected $_count = 0; public function insert($value) { $index = ++$this->_c原创 2011-03-10 11:25:00 · 538 阅读 · 0 评论 -
PHP实现Levenshtein Distance算法
Levenshtein Distance算法可用于计算2个文本的近似度,PHP提供了levenshtein的字符串函数,但在实际使用过程中发现,该实现有2个缺点:1.不支持多字节编码2.字符串不能超过255个字节自己实现如下: 0 && $len2 > 0) { if(mb_substr($str1, $i, 1) != mb_substr($str2, $i, 1)) { break; } $i++原创 2011-03-07 16:41:00 · 905 阅读 · 0 评论 -
调用symfony doctrine 生成的 form出错
<br />代码很简单<br /> <br />class customerActions extends sfActions { public function executeRegister(sfWebRequest $request){ $this->form = new CustomerForm(); } }<br />Customer由task, doctrine:build-forms自动生成。<br /> <br />本想节约时间的,没想到竟然出错了。。。不知因何原因原创 2010-07-16 17:42:00 · 440 阅读 · 0 评论 -
15 Most Important Considerations when Choosing a Web Development Framework
http://net.tutsplus.com/tutorials/other/15-most-important-considerations-when-choosing-a-web-development-framework/原创 2009-12-08 17:36:00 · 224 阅读 · 0 评论 -
PHP实现PING
<?php// Checksum calculation functionfunction icmpChecksum($data){ if (strlen($data)%2) $data .= "/x00"; $bit = unpack(n*, $data); $sum = array_sum($bit); while (原创 2011-06-09 11:38:00 · 295 阅读 · 0 评论