<?php $user_id = 1; $token = $this->getAccessToken(); $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $token; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url); curl_setopt($ch1, CURLOPT_POST, 1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); //curl_setopt($ch1, CURLOPT_POSTFIELDS, '{"expire_seconds": 604800, "action_name": "QR_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$user_id.'"}}}'); curl_setopt($ch1, CURLOPT_POSTFIELDS, '{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$user_id.'"}}}'); $c = curl_exec($ch1); $result = @json_decode($c, true); $ticket = $result["ticket"]; $qr_path = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$ticket; $bigImgPath = "xxxxxxxxxxx.png"; $bigImg = imagecreatefromstring(file_get_contents($bigImgPath)); $qCodeImg = imagecreatefromstring(file_get_contents($qr_path)); $save_width = 200; $save_height = 200; list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qr_path); $new_image = imagecreatetruecolor($save_width, $save_height); $s = imagecopyresampled($new_image, $qCodeImg, 0, 0, 0, 0, $save_width, $save_height, $qCodeWidth, $qCodeHight); imagecopymerge($bigImg, $new_image, 265, 370 , 0, 0, $save_width, $save_height, 100); $img_path = time().rand(100000,999999).'.jpg'; imagejpeg($bigImg,'xxxxxxx/images/'.$img_path); include $this->template('code');
JAVA 子类调用父类方法时,方法中的变量用谁的?
public class T1 { private int a=6; public void ha(){ System.out.println(this.a); } }
public class T2 extends T1{ int a=7; }
public class Test { public static void main(String[] args) { new T2().ha(); } }
输出结果为6
结论:子类调用父类方法时,方法中的变量用父类的
这个结果是很有意思的,我之前以为既然是子类调用父类的方法 那么应该是子类自动继承了父类 然后在自己类的内部使用自己的变量
没想到会使用父类内定义的变量值
json_encode只能用于utf8
json_encode只能用于utf8 别的编码下中文使用json_encode会编译不过去
宝塔面板 gitee webhook
#!/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)
/** * 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不是闭包 就转换成闭包
$this->getClosure($abstract, $concrete);
绑定自身的话可以看到返回的是
return $container->build($concrete);
大概可以理解成
$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时进行区分大小写的匹配。
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
小程序商城原型图
小程序点餐系统原型图
KFC小程序原型图
composer dump-autoload
修改了composer.json文件后需要执行一下
composer dump-autoload