1.可以設(shè)置密碼復(fù)雜規(guī)則(包含字母+特殊符號(hào)+數(shù)字+大小寫)
2.設(shè)置控制同一時(shí)間段內(nèi)密碼錯(cuò)誤登錄次數(shù)
dingo API: A RESTful API package for the Laravel framework
最近好像是支持 Lumen 了,用來做 API 應(yīng)該很合適。
我暫時(shí)用的也是swoole_table,不然就是用redis或者別的外置的存儲(chǔ)
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var htmlstr = template('fcat-tpl',{fcatData:fcatData});
1、set進(jìn)去的數(shù)據(jù)就是有序和不重復(fù)的,所以不會(huì)出現(xiàn)重復(fù)的情況
2、你每次執(zhí)行成功之后就要?jiǎng)h除集合里面的數(shù)據(jù)
3、如果執(zhí)行失敗就將失敗的數(shù)據(jù)存放在另一個(gè)集合中使用多線程進(jìn)行同步處理
1、文檔模式
沒有文檔模式時(shí),是處于混雜模式下,html 和 body 會(huì)充滿全屏。
<!DOCTYPE html> 會(huì)開啟標(biāo)準(zhǔn)模式,標(biāo)準(zhǔn)模式下默認(rèn) html 和 body 沒有高度。
這時(shí)可以這樣設(shè)置。
html, body {
height: 100%;
margin: 0;
padding: 0;
}
2、傳入事件
如果是在 html 標(biāo)簽中,想傳入事件,應(yīng)該用 event 而不是 e 。
<body onmousedown="show_coords(event)">
(.*).(doc|pdf)
個(gè)人推薦使用 switch
switch (variable) {
case 'value':
# code...
break;
default:
# code...
break;
}
下載官方案例 查看就行了 官方PHP SDK
下載之后查看里面的案例就行了
或者你看我根據(jù)官方 SDK 打 packagist 包 masterton/alipay-sdk-php
redis通過一致性hash算法保證寫入時(shí)的服務(wù)器和讀取時(shí)的服務(wù)器在一臺(tái)來解決分布式環(huán)境問題。你的問題太過模糊,現(xiàn)在已經(jīng)遇到集群性能瓶頸了?
看看設(shè)置里面有無.php
你看看這個(gè)行不行, 大概也就這樣思路.
/**
* 紅包分配算法
*
* example
* $coupon = new Coupon(200, 5);
* $res = $coupon->handle();
* print_r($res);
*
* @author Flc <2018-04-06 20:09:53>
* @see http://flc.ren | http://flc.io | https://github.com/flc1125
*/
class Coupon
{
/**
* 紅包金額
*
* @var float
*/
protected $amount;
/**
* 紅包個(gè)數(shù)
*
* @var int
*/
protected $num;
/**
* 領(lǐng)取的紅包最小金額
*
* @var float
*/
protected $coupon_min;
/**
* 紅包分配結(jié)果
*
* @var array
*/
protected $items = [];
/**
* 初始化
*
* @param float $amount 紅包金額(單位:元)最多保留2位小數(shù)
* @param int $num 紅包個(gè)數(shù)
* @param float $coupon_min 每個(gè)至少領(lǐng)取的紅包金額
*/
public function __construct($amount, $num = 1, $coupon_min = 0.01)
{
$this->amount = $amount;
$this->num = $num;
$this->coupon_min = $coupon_min;
}
/**
* 處理返回
*
* @return array
*/
public function handle()
{
// A. 驗(yàn)證
if ($this->amount < $validAmount = $this->coupon_min * $this->num) {
throw new Exception('紅包總金額必須≥'.$validAmount.'元');
}
// B. 分配紅包
$this->apportion();
return [
'items' => $this->items,
];
}
/**
* 分配紅包
*/
protected function apportion()
{
$num = $this->num; // 剩余可分配的紅包個(gè)數(shù)
$amount = $this->amount; //剩余可領(lǐng)取的紅包金額
while ($num >= 1) {
// 剩余一個(gè)的時(shí)候,直接取剩余紅包
if ($num == 1) {
$coupon_amount = $this->decimal_number($amount);
} else {
$avg_amount = $this->decimal_number($amount / $num); // 剩余的紅包的平均金額
$coupon_amount = $this->decimal_number(
$this->calcCouponAmount($avg_amount, $amount, $num)
);
}
$this->items[] = $coupon_amount; // 追加分配
$amount -= $coupon_amount;
--$num;
}
shuffle($this->items); //隨機(jī)打亂
}
/**
* 計(jì)算分配的紅包金額
*
* @param float $avg_amount 每次計(jì)算的平均金額
* @param float $amount 剩余可領(lǐng)取金額
* @param int $num 剩余可領(lǐng)取的紅包個(gè)數(shù)
*
* @return float
*/
protected function calcCouponAmount($avg_amount, $amount, $num)
{
// 如果平均金額小于等于最低金額,則直接返回最低金額
if ($avg_amount <= $this->coupon_min) {
return $this->coupon_min;
}
// 浮動(dòng)計(jì)算
$coupon_amount = $this->decimal_number($avg_amount * (1 + $this->apportionRandRatio()));
// 如果低于最低金額或超過可領(lǐng)取的最大金額,則重新獲取
if ($coupon_amount < $this->coupon_min
|| $coupon_amount > $this->calcCouponAmountMax($amount, $num)
) {
return $this->calcCouponAmount($avg_amount, $amount, $num);
}
return $coupon_amount;
}
/**
* 計(jì)算分配的紅包金額-可領(lǐng)取的最大金額
*
* @param float $amount
* @param int $num
*/
protected function calcCouponAmountMax($amount, $num)
{
return $this->coupon_min + $amount - $num * $this->coupon_min;
}
/**
* 紅包金額浮動(dòng)比例
*/
protected function apportionRandRatio()
{
// 60%機(jī)率獲取剩余平均值的大幅度紅包(可能正數(shù)、可能負(fù)數(shù))
if (rand(1, 100) <= 60) {
return rand(-70, 70) / 100; // 上下幅度70%
}
return rand(-30, 30) / 100; // 其他情況,上下浮動(dòng)30%;
}
/**
* 格式化金額,保留2位
*
* @param float $amount
*
* @return float
*/
protected function decimal_number($amount)
{
return sprintf('%01.2f', round($amount, 2));
}
}
此代碼轉(zhuǎn)載至PHPhuo.org用戶葉子坑, 侵刪!
PHP 實(shí)現(xiàn)微信紅包拆分算法
$a + $a++
中先執(zhí)行 $a++
, $a被壓到棧中,值為3. 然后執(zhí)行++操作后$a變?yōu)?, 值為4的a被壓到棧中。
然后使用棧中的兩個(gè)值執(zhí)行加法操作,得7
示意圖
$a(3) -> $a(4) -> 加法操作 4 + 3
可以看出前面參與計(jì)算的$a是4, 后面參與計(jì)算的$a是3
你可以看看tp中session函數(shù)源碼, 是否有前綴.
找到問題所在了,xml格式的數(shù)據(jù)標(biāo)簽里面不能含有任何空格,去掉就好了,好坑啊,之前一直是json通訊,第一次接觸xml采坑了
估計(jì)是語法錯(cuò)誤,你看網(wǎng)頁之前有個(gè)引號(hào),你肯定是把他網(wǎng)頁輸出了、不如貼出你的控制器代碼
iconv('GBK', 'UTF-8//IGNORE', $content_of_csv);
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國成功上市,融資1
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。