PHP code example of jerry58321 / probability-random
1. Go to this page and download the library: Download jerry58321/probability-random library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jerry58321 / probability-random example snippets
use Jerry58321\ProbabilityRandom\ProbabilityRandom;
$min = 1; // 最小值
$max = 100; // 最大值
$probabilityRandom = ProbabilityRandom::build($min, $max);
// 注意:build method 第三個參數為是否使用安全區間,
// 若設定不啟用(false)時,遇到 min > max 情況時則會拋出例外,預設為(true)。
// 若採用預設啟用(true),遇到 min > max 情況時則不採用區間機率(等於使用 random_int)