鍍金池/ 問答/ PHP問答
礙你眼 回答

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ǔ)

獨(dú)白 回答

$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)">
毀了心 回答

個(gè)人推薦使用 switch

switch (variable) {
    case 'value':
        # code...
        break;
    
    default:
        # code...
        break;
}
祉小皓 回答

下載官方案例 查看就行了 官方PHP SDK
下載之后查看里面的案例就行了

或者你看我根據(jù)官方 SDK 打 packagist 包 masterton/alipay-sdk-php

厭惡我 回答

是跟隨用戶的,發(fā)送的時(shí)候要對(duì)應(yīng)用戶的 openId

A 用戶點(diǎn)擊按鈕后,收集到 formidA 用戶的 openId,然后就可以給 A 用戶發(fā)送模板消息了。

小程序的文檔

柒喵 回答

redis通過一致性hash算法保證寫入時(shí)的服務(wù)器和讀取時(shí)的服務(wù)器在一臺(tái)來解決分布式環(huán)境問題。你的問題太過模糊,現(xiàn)在已經(jīng)遇到集群性能瓶頸了?

  1. redis集群服務(wù)器配置?
  2. redis集群服務(wù)器有多少臺(tái)?
忠妾 回答

clipboard.png
看看設(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)頁輸出了、不如貼出你的控制器代碼