上一页 1 2 3 4 5 6 ··· 10 下一页

2012年1月5日

摘要: PHP performance tipsAuthor: Eric Higgins, Google WebmasterRecommended experience: Beginner to intermediate PHP knowledgePHP is a very popular scripting language, used on many popular sites across the web. In this article, we hope to help you to improve the performance of your PHP scripts with some c 阅读全文
posted @ 2012-01-05 16:25 天空尚兰 阅读(257) 评论(0) 推荐(0) 编辑

2011年12月28日

摘要: $this->db->select('id,name'); $this->db->from('category'); //注意sql语句中如果要加括号好像不行,只能自己写条件 //$this->db->where("is_show",'1'); // $this->db->or_where("id","3)"); ... 阅读全文
posted @ 2011-12-28 14:04 天空尚兰 阅读(907) 评论(0) 推荐(1) 编辑
摘要: <?phpinterface IUser { function getName(); function setName($_name); function getDiscount(); //此处添加了一个抽象的方法} class VipUser implements IUser { private $name; private $discount = 0.8; //折扣变量 function getName() { return $this->name; } function setName($_name) { $this->name = $_name; } fu... 阅读全文
posted @ 2011-12-28 11:56 天空尚兰 阅读(326) 评论(0) 推荐(0) 编辑
摘要: <?phpinterface User { function getName(); function setName($_name); } interface VipUser extends User //VipUser继承User接口{ function getDiscount(); //此处添加了一个抽象的方法 } class Vip implements VipUser { private $name; private $discount = 0.8; //折扣变量 function getName() { return $this->name; } function set 阅读全文
posted @ 2011-12-28 11:00 天空尚兰 阅读(222) 评论(0) 推荐(0) 编辑

2011年12月12日

摘要: 关于数组排序,PHP内置了shuffle()函数,可以重排数组排序,但是此函数“将删除原有的键名而不仅是重新排序”,如果传入的是关联数组,则关联数组的键名将丢失。 解决方法如下:关联数组和索引数组都可以用function array_shuffle($array){ //不是数组 if(!is_array($array)) { return array(); } //如果为空或者只有1项 if(($count=count($array))<=1){ return $array; } //得到打乱的键 $r... 阅读全文
posted @ 2011-12-12 15:06 天空尚兰 阅读(620) 评论(0) 推荐(1) 编辑

2011年12月8日

摘要: // 用preg_match 模仿实现 preg_match_allfunction custom_preg_match_all($pattern, $subject){ $offset = 0; $match_count = 0; while(preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, $offset)) { // Increment counter $match_count++; // Get byte offset and byte l... 阅读全文
posted @ 2011-12-08 14:31 天空尚兰 阅读(213) 评论(0) 推荐(0) 编辑

2011年12月6日

摘要: function dirSize($directory){ $dir_size=0; if($dir_handle=@opendir($directory)) { while($filename=readdir($dir_handle)) { if($filename!="." && $filename!="..") { $subFile=$directory."/".$filename; if(is_dir($subFile)) { $dir_size+=dirSize($subFile); }... 阅读全文
posted @ 2011-12-06 15:55 天空尚兰 阅读(161) 评论(0) 推荐(0) 编辑
摘要: /自己写的一个PDO类class CPdo{protected $_dsn = "mysql:host=localhost;dbname=test";protected $_name = "root";protected $_pass = "";protected $_condition = array();protected $pdo;protected $fetchAll;protected $query;protected $result;protected $num;protected $mode;protected $pre 阅读全文
posted @ 2011-12-06 15:26 天空尚兰 阅读(269) 评论(0) 推荐(0) 编辑
摘要: <?php$str="this is a test \n";$patten = array("\r\n", "\n", "\r"); //先替换掉\r\n,然后是否存在\n,最后替换\r $str=str_replace($order, "", $str);?> //php 有三种方法来解决 //1、使用str_replace 来替换换行 $str = str_replace(array("\r\n", "\r", "\n" 阅读全文
posted @ 2011-12-06 14:56 天空尚兰 阅读(2516) 评论(0) 推荐(0) 编辑

2011年12月2日

摘要: <?phpclass sample implements Iterator { private $_items = array (0, 1, 2, 3 ); public function __construct() { ; //void } public function rewind() { reset ( $this->_items ); } public function current() { return current ( $this->_items ); } public functio... 阅读全文
posted @ 2011-12-02 18:01 天空尚兰 阅读(363) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页

导航