本文介紹了PHP 短哈希,如 URL 縮短網站的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在尋找一個 PHP 函數,它可以從字符串或文件中創建一個簡短的散列,類似于那些 URL 縮短網站,如 tinyurl.com
I am looking for a PHP function that creates a short hash out of a string or a file, similar to those URL-shortening websites like tinyurl.com
哈希不應超過 8 個字符.
The hash should not be longer than 8 characters.
推薦答案
URL 縮短服務,而是使用自動遞增的整數值(如補充數據庫 ID)并使用 Base64 或其他編碼,以便為每個字符提供更多信息(64 而不是像數字一樣只有 10 個).
URL shortening services rather use a auto incremented integer value (like a supplementary database ID) and encode that with Base64 or other encodings to have more information per character (64 instead of just 10 like digits).
這篇關于PHP 短哈希,如 URL 縮短網站的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!