json_encode只能用于utf8 别的编码下中文使用json_encode会编译不过去
月度归档: 2019年7月
宝塔面板 gitee webhook
1 |
#!/bin/bash
echo ""
#输出当前时间
date –date='0 days ago' "+%Y-%m-%d %H:%M:%S"
echo "Start"
#判断宝塔WebHook参数是否存在
if [ ! -n "$1" ]; then
echo "param参数错误"
echo "End"
exit
fi
#git项目路径
gitPath="/www/wwwroot/$1"
#git 网址
gitHttp="https://gitee.com/iamleokim/cyhl.git"
echo "Web站点路径:$gitPath"
#判断项目路径是否存在
if [ -d "$gitPath" ]; then
cd $gitPath
#判断是否存在git目录
if [ ! -d ".git" ]; then
echo "在该目录下克隆 git"
sudo git clone $gitHttp gittemp
sudo mv gittemp/.git .
sudo rm -rf gittemp
fi
echo "拉取最新的项目文件"
sudo git reset –hard origin/master
sudo git pull
echo "设置目录权限"
sudo chown -R www:www $gitPath
echo "End"
exit
else
echo "该项目路径不存在"
echo "新建项目目录"
mkdir $gitPath
cd $gitPath
#判断是否存在git目录
if [ ! -d ".git" ]; then
echo "在该目录下克隆 git"
sudo git clone $gitHttp gittemp
sudo mv gittemp/.git .
sudo rm -rf gittemp
fi
echo "拉取最新的项目文件"
sudo git reset –hard origin/master
sudo git pull
echo "设置目录权限"
sudo chown -R www:www $gitPath
echo "End"
exit
fi
Laravel源码分析(bind)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /** * Register a binding with the container. * * @param string $abstract * @param \Closure|string|null $concrete * @param bool $shared * @return void */ public function bind( $abstract , $concrete = null, $shared = false) { $this ->dropStaleInstances( $abstract ); // If no concrete type was given, we will simply set the concrete type to the // abstract type. After that, the concrete type to be registered as shared // without being forced to state their classes in both of the parameters. if ( is_null ( $concrete )) { $concrete = $abstract ; } // If the factory is not a Closure, it means it is just a class name which is // bound into this container to the abstract type and we will just wrap it // up inside its own Closure to give us more convenience when extending. if (! $concrete instanceof Closure) { $concrete = $this ->getClosure( $abstract , $concrete ); } $this ->bindings[ $abstract ] = compact( 'concrete' , 'shared' ); // If the abstract type was already resolved in this container we'll fire the // rebound listener so that any objects which have already gotten resolved // can have their copy of the object updated via the listener callbacks. if ( $this ->resolved( $abstract )) { $this ->rebound( $abstract ); } } /** * Drop all of the stale instances and aliases. * * @param string $abstract * @return void */ protected function dropStaleInstances( $abstract ) { unset( $this ->instances[ $abstract ], $this ->aliases[ $abstract ]); } /** * Get the Closure to be used when building a type. * * @param string $abstract * @param string $concrete * @return \Closure */ protected function getClosure( $abstract , $concrete ) { return function ( $container , $parameters = []) use ( $abstract , $concrete ) { if ( $abstract == $concrete ) { return $container ->build( $concrete ); } return $container ->resolve( $concrete , $parameters , $raiseEvents = false ); }; } /** * Determine if the given abstract type has been resolved. * * @param string $abstract * @return bool */ public function resolved( $abstract ) { if ( $this ->isAlias( $abstract )) { $abstract = $this ->getAlias( $abstract ); } return isset( $this ->resolved[ $abstract ]) || isset( $this ->instances[ $abstract ]); } /** * Fire the "rebound" callbacks for the given abstract type. * * @param string $abstract * @return void */ protected function rebound( $abstract ) { $instance = $this ->make( $abstract ); foreach ( $this ->getReboundCallbacks( $abstract ) as $callback ) { call_user_func( $callback , $this , $instance ); } } |
bind第一步是销毁了之前绑定的instances和aliases,如果$concrete是空,那么就绑定$abstract自己
如果concrete不是闭包 就转换成闭包
1 | $this ->getClosure( $abstract , $concrete ); |
绑定自身的话可以看到返回的是
return $container->build($concrete);
大概可以理解成
1 2 3 4 5 6 7 8 9 10 11 12 | $bindings = [ 'HelpSpot\API' => [ //闭包绑定 'concrete' => function ( $app , $paramters = []) { return $app ->build( 'HelpSpot\API' ); }, 'shared' => false //如果是singleton绑定,这个值为true ] 'Illuminate\Tests\Container\IContainerContractStub' => [ //接口实现绑定 'concrete' => 'Illuminate\Tests\Container\ContainerImplementationStub' , 'shared' => false ] ] |
SUBSTRING_INDEX(str,delim,count)
返回从字符串str分隔符delim中的计数发生前的子字符串。 如果计数是正的,则返回一切到最终定界符(从左边算起)的左侧。如果count为负,则返回一切到最后一个分隔符(右算起)的右侧。SUBSTRING_INDEX() 搜索delim时进行区分大小写的匹配。
1 2 3 4 5 6 7 8 9 | select * , concat(SUBSTRING_INDEX(remarks, 'NRIC: ' , 1), "Ref No.: " , SUBSTRING_INDEX(remarks, 'Ref No.: ' , -1)) as new_remarks #, SUBSTRING_INDEX(remarks, 'NRIC: ' , 1) as before_nric #, SUBSTRING_INDEX(remarks, 'Ref No.: ' , -1) as after_ref_no from voucher_action where action_id in (30, 32) and remarks like '%NRIC: %' order by id desc limit 100 |