Php generates short domain name functions. Php has generated a short domain name function. The short website has been popular for some time. I used to have contact with Sina Weibo apps before, but I have not figured it out. recently I have come into contact with this stuff again, carefully generate short domain name functions in php
The short website has been popular for some time. I used to have contact with Sina Weibo apps before, but I have not figured it out. recently I have come into contact with this stuff and studied it carefully, it is also easy to find short URLs. The following describes how to generate a short URL using php.
Php short domain name generation function
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 |
Public function createRandCode ($ string ){
$ Code = '';
$ Hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p _';
$ Now = microtime (true) * 10000;
$ Strlen = strlen ($ hex_code );
$ Hash_code = hash ('sha256 ', $ string );
// A random length is defined for the encoding. the length depends on the step.
$ Step = rand (8, 16 );
$ Count = ceil (strlen ($ hash_code)/$ step );
For ($ I = 0; $ I <$ count; $ I ++ ){
$ Start = $ I * $ step;
$ Hex_num = substr ($ hash_code, $ start, $ step );
$ Num = 0x3fffffff & (1 * '0x '. $ hex_num );
$ N = $ num % $ strlen;
$ Code. = $ hex_code [$ n];
}
Return $ code;
}
|
The above is all the content of the code shared in this article. I hope you will like it.
The short Web site has been popular for some time. I used to have contact with Sina Weibo apps before, but I didn't know it clearly. recently I 've come to contact this stuff again. please be careful...