From 062fc4b97f75ffc94fb94d61b1f480e714c7f26c Mon Sep 17 00:00:00 2001
From: Alexchent <1023615292@qq.com>
Date: Thu, 16 Jan 2020 14:49:47 +0800
Subject: [PATCH] update README
---
.gitignore | 2 +-
Cache/Redis.php | 127 -----------------------------------------------
Helper/Tools.php | 75 ++++++++++++----------------
autoload.php | 1 +
4 files changed, 35 insertions(+), 170 deletions(-)
delete mode 100644 Cache/Redis.php
create mode 100644 autoload.php
diff --git a/.gitignore b/.gitignore
index 91c08b8..f09907d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/.idea
/vendor
\ No newline at end of file
+.idea
/vendor
\ No newline at end of file
diff --git a/Cache/Redis.php b/Cache/Redis.php
deleted file mode 100644
index 749a372..0000000
--- a/Cache/Redis.php
+++ /dev/null
@@ -1,127 +0,0 @@
-redis = new redis();
- //redis-cli -h 127.0.0.1 -p 6379
- $this->redis->connect(self::HOST, self::PORT);
- }
-
- function down(){
- if($this->redis){
- $this->redis->close();
- }
- }
- //查看服务是否运行
- public function ping(){
- echo "Server is running: " . $this->redis->ping();
- echo "
";
- }
-
- /*
- * 查看redis信息
- */
- function testInfo(){
- $info = $this->redis->info();
- var_dump($info);
- echo "
";
- }
-
-
- #字符串
-
-
- function setStr($key,$value){
- $rs = $this->redis->set($key,$value);
- return $rs;
- }
-
- function getStr($key){
- echo "stored string in redis::".$this->redis->get($key).'
';
- echo "得到键值的长度::".$this->redis->strlen($key).'
';
- }
-
-
- /**设置多个键和多个值
- * @param $arr 参考格式::$arr = array('sex'=>'men','address'=>'njupt');
- * @return bool
- */
- function setStrs($arr){
- $rs = false;
- if(isset($arr)&&count($arr)>0){
-
- $rs = $this->redis->mset($arr);
- }
- return $rs;
- }
-
- /**删除字符串键值对
- *
- * @param string $key
- * @return mixed
- */
- function delStr($key='sex'){
- $rs = $this->redis->del($key);
- return $rs;
- }
-
- #hash表
- /**
- * @param $hash
- * @param $key
- * @param $value
- * @return mixed
- */
- function setHash($hash,$key,$value){
- $rs = $this->redis->HSET($hash,$key,$value);
- //$redis->HSET('hashkey1','fail','world');
- return $rs;
- }
-
- function getHash($hash,$key){
- var_dump( $this->redis->HGET($hash,$key) );
- echo "
";
- }
-
-
-
- #列表
- function setList(){
- $rs = $this->redis->lpush('test_list','chentao','shanghai','25','men');
- return $rs;
- }
-
- function getList($list='test_list'){
- //echo "删除::".$redis->lrem('list1',0,'chentao').'
';
- echo "
";
- var_dump($this->redis->lrange($list,0,-1));
- echo "
";
- }
- // var_dump($redis->TYPE('test_list'));
-
-
- #集合
- /**
- * 操作有序集合
- * @param string $z 集合名
- * @param int $index
- * @param string $value
- */
- function setz($z,$index,$value){
- $this->redis->zadd($z,$index,$value);
- }
-
- /**获取集合
- * @param $z 集合名
- */
- function getz($z){
- $rs = $this->redis->zrange($z,0,-1);
- return $rs;
- }
-
-
- }
-
-?>
diff --git a/Helper/Tools.php b/Helper/Tools.php
index 4142969..8cdfec2 100755
--- a/Helper/Tools.php
+++ b/Helper/Tools.php
@@ -222,6 +222,36 @@ public static function getBC($zh){
return $ret;
}
+ /**
+ * 生成简码
+ *
+ * @param string $name 名称,由数字英文字母或汉字组成
+ *
+ * @return string
+ * @author tao.chen
+ */
+ public static function createBC($name)
+ {
+ $bc = '';
+ $len = mb_strlen($name, "UTF8");
+ for ($i = 0; $i < $len; $i++) {
+ $charter = mb_substr($name, $i, 1, "UTF8");
+ if (preg_match("/[a-zA-Z0-9]/", $charter)) {
+ //匹配到是英文字母或数字,直接输入
+ $firstCharter = strval(strtoupper($charter));
+ } else {
+ //只接受汉字,其他返回null
+ $firstCharter = self::getFirstCharter($charter);
+ }
+ $bc .= $firstCharter;
+ }
+ if (empty($bc)) {
+ $bc = '*';
+ }
+ $bc = substr($bc, 0, 10);
+ return $bc;
+ }
+
/**
* 选定数组的某个值做key重组数组
* 适用于二维数组
@@ -265,35 +295,7 @@ public static function match_chinese($chars, $encoding = 'utf8')
- /**
- * 生成简码
- *
- * @param string $name 名称,由数字英文字母或汉字组成
- *
- * @return string
- * @author tao.chen
- */
- public static function createBC($name)
- {
- $bc = '';
- $len = mb_strlen($name, "UTF8");
- for ($i = 0; $i < $len; $i++) {
- $charter = mb_substr($name, $i, 1, "UTF8");
- if (preg_match("/[a-zA-Z0-9]/", $charter)) {
- //匹配到是英文字母或数字,直接输入
- $firstCharter = strval(strtoupper($charter));
- } else {
- //只接受汉字,其他返回null
- $firstCharter = self::getFirstCharter($charter);
- }
- $bc .= $firstCharter;
- }
- if (empty($bc)) {
- $bc = '*';
- }
- $bc = substr($bc, 0, 10);
- return $bc;
- }
+
public static function isNotJson($str)
{
@@ -328,11 +330,10 @@ public static function getRelativePath($a, $b)
$path = '';
$arr = explode('/', $a);
$brr = explode('/', $b);
-// var_dump($brr);
+
$same = array_intersect_assoc($arr, $brr);//获取两个数组相同的部分
-//var_dump($same);
$dir = array_diff_assoc($brr, $same);
-// var_dump($dir);die;
+
for($i = 1; $i <= count($dir)-1; $i++) {
$path .='../';
}
@@ -342,14 +343,4 @@ public static function getRelativePath($a, $b)
return $path;
}
-
- public static function getmicrotime(){
- list($u,$s) = explode('', microtime());
- $num = (float)$u + (float)$s;
- return sprintf("%.4f", $num);
-
- }
-
-
-
}
diff --git a/autoload.php b/autoload.php
new file mode 100644
index 0000000..03b5a53
--- /dev/null
+++ b/autoload.php
@@ -0,0 +1 @@
+