随笔分类 - PHP
摘要:$(".area").change(function(ent,arg){ var $this = $(this), level = $(this).attr("id"); $.ajax({ url:'/Order/selectAddress', data:{l:level,type:'ajax'...
阅读全文
摘要:php $xml = simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA']); $arr = array( 'appid'=> (string)$xml->AppId, 'appkey'=>$appkey, 'issubscribe'=> (st...
阅读全文
摘要:1、 查看DAO 生成的sql 结果(类似TP的 getLastSql): $reto = $edb->createCommand($bsql); echo $reto->text;2、Yii获取客户端IPYii::app()->request->userHostAddress;3、获取iframe元素 var iframe = document.getElementsByName("goods_list")[0]; iframe.onload = iframe.onreadystatechange = function() { $(iframe.c
阅读全文
摘要:w = $w; $this->isEnd = $isEnd; } } public function insert( $str ){ $len = strlen($str); if(!$len) return ; $scope = $this; for( $i = 0; $i 127 ){ $cStr = substr($str, $i, 3); $i += 2; } $scope...
阅读全文
摘要:$str = "abcdef啊啊吧啊";function my_sub($str, $st ,$len){ $ret = ""; for( $st; $len > 0; $st++){ $cStr = $str[$st]; if( ord( $cStr ) > 127 ){ $cStr = substr($str, $st, 3); $st += 2; } $len -= 1; $ret .= $cStr; } return $ret;} echo my_s...
阅读全文
摘要:w = $w; $this->isEnd = $isEnd; } } public function insert( $str ){ $len = strlen($str); if(!$len) return ; $scope = $this; for( $i = 0; $i 127 ){ $cStr = substr($str, $i, 3); $i += 2; } $scope...
阅读全文
摘要:foreach ($list as $k=> $teamGoods){ if($teamGoods['status'] > 4){ $_soldGoods[] = $teamGoods; unset($list[$k]); } } $list = array_merge($list, $_soldGoods);当没有状态为4的商品的时候合并数据 导致$list 为空以后还是先确定合并的参数为数组把。。 若类型果然坑人- -解决: $_sol...
阅读全文
摘要:k = $k; $this->left = $left; $this->right = $right; } public function isEmpty(){ return !isset($this->k); } public function getKey(){ return isset($this->k) ? $this->k : false; } public function setKey($k){ if(!$this->isEmpty()...
阅读全文
摘要:function get_hash_table($table,$uid){ $_str = crc32($uid); if($_str < 0 ){ $ret = "0".substr(abs($_str),0,1); }else{ $ret = substr($_str,0,2); } return $table."_".$ret;} echo get_hash_table('test','user1'); //test_01echo get_hash_table('test','dddda
阅读全文
摘要:今儿开发过程中发现 tp是unset 变量失败。。具体代码foreach( $this->menu as $k => $v){ if(0 == $v['flag']) unset($this->menu[$k]);}逻辑很简单。。但是居然没过滤掉menu里面的值。。一番折腾后发现居然是 TP 底层重写了 __set __get 造成的 具体代码 public function __construct() { //实例化视图类 $this->view = Think::instance('View'); /...
阅读全文
摘要:If you wan't to use the alternative syntax for switch statements this won't work:NewspageForumInstead you have to workaround like this:NewspageForum看了半天原来是PHP 的BUG。。。 唉。。。switch : 和 case 之间是不能有任何输出的。。。 PS : 一个空格也不行。。you may see the comment in thislink........
阅读全文
摘要:定义和用法array_unique() 函数移除数组中的重复的值,并返回结果数组。当几个数组元素的值相等时,只保留第一个元素,其他的元素被删除。返回的数组中键名不变。语法array_unique(array)参数描述array必需。规定输入的数组。说明array_unique() 先将值作为字符串排序,然后对每个值只保留第一个遇到的键名,接着忽略所有后面的键名。这并不意味着在未排序的array中同一个值的第一个出现的键名会被保留。提示和注释注释:被返回的数组将保持第一个数组元素的键类型。例子"Cat","b"=>"Dog",&q
阅读全文
摘要:function connect_oracle(){ static $dbconn = false; if(!$dbconn){ $db_server = "127.0.0.1"; $db_user = "zzzz"; $db_pass = "zzzzzz123"; $db_sid = "MBDWV2"; $dbconn = OCILogon($db_user,$db_pass,"(DESCRIPTION = (ADDRESS_LIST = ...
阅读全文
摘要:$colunm){ $this->_column[$k] = $colunm['title']; $this->_reg[$k]['reg'] = $colunm['reg']; $this->_reg[$k]['colunm'] = $colunm['name']; } return $this; } public function bulidData($data){ $this->ret = implode(",", $t...
阅读全文
摘要:网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定。我们假设http服务器运行的用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web。方法/步骤1我们首先设定网站目录和文件的所有者和所有组为centos,www,如下命令:chown -R centos:www /home/centos/web2设置网站目录权限为750,750是centos用户对目录拥有读写执行的权限,这样centos用户可以在任何目录下创建文件,用户组有有读执行权限,这样才能进入目录,其它用户没有任何权限。find -type d -exec chmod
阅读全文
摘要:attach($this); $this->_m[] = $behaviorObj; } public function __call($method,$param){ foreach($this->_m as $obj){ if(method_exists($obj,$method)){ call_user_func(array($obj,$method),$param); } } }}class Behavior{ protected $scop...
阅读全文
摘要:1.给子域名加www标记RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC]RewriteCond %{HTTP_HOST} !^www\. [NC]RewriteRule .? http://www.xample.com%{REQUEST_URI} [R=301,L]这个规则抓取二级域名的%1变量,如果不是以www开始,那么就加www,以前的域名以及{REQUEST_URI}会跟在其后。2.去掉域名中的www标记RewriteCond %{HTTP_HOST} !^example\.com$ [NC]RewriteRule .? ht
阅读全文
摘要:_e[$name])) $this->_e[$name] = array(); return array_push($this->_e[$name] , $value); } } public function __get($name){ if( strncasecmp($name,"on",2) === 0 ){ if(!isset($this->_e[$name])) $this->_e[$name] = array(); ...
阅读全文
摘要:";function modify( $a){ foreach($a as &$v){ $v = 'dddddd'; }}modify(&$arr);//print_r($arr);echo memory_get_usage()."";/* * 338344 * 343112 *//* * @2$arr = array_fill(1,100,'bbb');echo memory_get_usage()."";function modify( &$a){ foreach($a as &
阅读全文
摘要:$ret = '';$arrs = array(array(1,'test1'), array(2,'test2'), array(3,'test3'), array(4,'test4'), array(5,'test5'), array(6,'test6'), array(7,'test7') );foreach($arrs as $k=>$arr){ $ret .= $arr[0].",".$arr[1]." \n";
阅读全文

浙公网安备 33010602011771号