把整數產生唯一字串的PHP函式庫
<?php /* * This file is part of Hashids. * (c) Ivan Akimov <ivan@barreleye.com> * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Hashids; use RuntimeException; /** * This is the math class. * @author Vincent Klaiber <hello@vinkla.com> * @author Jakub Kramarz <lenwe@lenwe.net> */ class Math { /** * Add two arbitrary-length integers. * @param string $a * @param string $b * @throws \RuntimeException * @return string */ public static function add($a, $b) { if (function_exists('gmp_add')) { return gmp_add($a, $b); } if (function_exists('bcadd')) { return bcadd($a, $b, 0); } throw new RuntimeException('Missing BC Math or GMP extension.'); }
字串或字串(String)是由數字、字母、底線組成的一串字元。一般記為 s=“a1a2···an”(n>=0)。它是程式語言中表示文字的資料類型。在程式設計中,字串(string)為符號或數值的一個連續序列,如符號串(一串字元)或二進位數字串(一串二進位數字)。
通常以字串的整體作為操作對象,如:在字串中尋找某個子字串、求取一個子字串、在字串的某個位置上插入一個子字串以及刪除一個子字串等。兩個字串相等的充要條件是:長度相等,且各個對應位置上的字元都相等。設p、q是兩串,求q在p中首次出現的位置的運算叫做模式匹配。串的兩種最基本的儲存方式是順序儲存方式和連結儲存方式。
免責聲明
本站所有資源皆由網友貢獻或各大下載網站轉載。請自行檢查軟體的完整性!本站所有資源僅供學習參考。請不要將它們用於商業目的。否則,一切後果都由您負責!如有侵權,請聯絡我們刪除。聯絡方式:admin@php.cn
相關文章

15Dec2024
資料儲存區 AllocateIDs 函數和字串鍵問題:資料儲存區中的 AllocateIDs 函數能否用於產生唯一字串識別碼...

28Oct2024
在 Linux 上查詢已安裝的 libstdc 庫版本查看已安裝的 libstdc 庫版本的一種常見方法包括提取...

07Dec2024
在 NetBeans 中設定類別路徑在 NetBeans 中使用 Java 時,您可能需要調整類別路徑以包含其他程式庫或 JAR...


Hot Tools

熱門文章
丟失記錄:Bloom&Rage -Corey和Dylan的鎖組合
19Feb2025手游攻略
Longvinter:完整的釣魚指南
21Feb2025手游攻略
KCD 2:Zhelejov Marshes的地圖位置和解決方案
19Feb2025手游攻略
Hello Kitty Island冒險:重新啟動機器人任務演練
16Feb2025手游攻略
丟失的唱片:Bloom&Rage-如何打開機艙門
19Feb2025手游攻略