Loading

邢栋博客

php获得字符串内字符的个数(包含中文)

function getstrlen($str,$charset="utf-8") { $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; $re['gbk'] = "/[\x01-\x7f]|[\x...

php截取字符串函数(兼容中文或中英文字符串)

function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) { if(function_exists("mb_substr")) $slice = mb_substr($str, $start, $length, $charset); elseif(function_exists('iconv_substr')) { $slice = iconv_substr($str,$star...

php加密解密(异或,base64,des)

前几天给pc端写接口用到数据加密,现在总结下,当时主要做的是对pc端传来的数据进行解密,现在用php模拟下加密以及解密 1.加密 第一步:先进行异或加密,然后在base64加密 function my_jiami($str){ //随机取8位数 for($i=0;$i<8;$i++){ $key.= rand(0,9); } $tmp=""; for($i=0;$i<strlen($str);$i++){ $tmp.=substr($...

网站后台ifarme下session失效后点击跳转到登陆页

<script type="text/javascript"> MyIndex = '{:U(MODULE_NAME."/Login/index")}';//为跳转链接 if (top.location != self.location){ top.location = MyIndex; } </script>

php获取本周,上周,本月,上月,本季度日期代码

$startweek = "本周开始时间:".date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-date("w")+1-7,date("Y"))); $endweek = "本周结束时间:".date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))); echo $startweek; echo "<br>"; echo $endweek; echo "<br>";...

把text文件内容导入mysql数据库

1.先针对文件创建一个数据表,如action,字段id,title,url 2.从text文件内容导入数据到mysql load data local infile “c:/data.txt” into table action(title,url); 3.把mysql里面的数据导入到text文件 select title,url into outfile “c:/data_out.txt” lines terminated by “/r/n” from action; MySQL 去除字段中的换行和回车符 /r/n update action set...

mysql数据库root密码丢失

Service mysqld stop Mysql_safe --skip-grant-tables --user=mysql& //跳过授权表mysql.user和mysql.db这些表 Mysql -uroot Update user set password = password(‘1314’) where user = ‘root’ and host=’localhost’; flush privileges;­

php常用的字符串处理函数

1、 查找字符位置函数 strpos($str,search,[int]):查找search在$str中的第一次位置从int开始; stripos($str,search,[int]):函数返回字符串在另一个字符串中第一次出现的位置。该函数对大小写不敏感 strrpos($str,search,[int]):查找search在$str中的最后一次出现的位置从int 2、提取子字符函数 substr($str,int start[,int length]):从$str中strat位置开始提取[length长度的字符串]。 strstr($str1,$str...

php数组关于键名和键值的常用函数

$array=array("Linux","Apache","MySQL","PHP"); print_r(array_keys($array)); //返回所有键名 //Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) print_r(array_keys($array,"PHP")); //返回值为PHP的键名 //Array ( [0] => 3 ) print_r(...

php数组与数据结构的函数,堆栈,队列,求和

1.使用数组实现堆栈 //后进后出 array_push() array_pop() //使用数组实现堆栈 $b=array(1,2,3,4); $b[]="a";//入栈 array_push($b,"b","c");//使用函数入栈,从最后的位置插入 print_r($b);//Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => a [5] => b [6] => c ) $value=array_p...