Php creates a short address (var_export) and submits the shorten. php :?? & Lt; formmethodpostactionshow. php & gt; & lt; inputtypetextnameurlvalue & gt; & l create a short address (var_export) in php)
Submit page shorten. php:
?
?
?
?
Processing page show. php:
?
?
');fclose($file);$output = 'Original Url : '.$url.'
Shorten Ulr : http://www.yourdomain.com/api/s='.$uif.'';}else $output = 'access error';}else{$uif = array_search($url,$shortUrls);$output = 'Original Url : '.$url.'
Shorten Ulr : http://www.yourdomain.com/api/s='.$uif.'';}echo $output.'
Back';}?>
?
?
Link page? Functions. php
?
?
0) $out -= pow($base, $pad_up);}$out = sprintf('%F', $out);$out = substr($out, 0, strpos($out, '.'));} else {// Digital number -->> alphabet letter codeif (is_numeric($pad_up)) {$pad_up--;if ($pad_up > 0) $in += pow($base, $pad_up);}$out = "";for ($t = floor(log($in, $base)); $t >= 0; $t--) {$bcp = bcpow($base, $t);$a = floor($in / $bcp) % $base;$out = $out . substr($index, $a, 1);$in = $in - ($a * $bcp);}$out = strrev($out); // reverse}return $out;}?>
?
?
Link page? Shorturls. php
?
?
?
?
?
Principle: store the submitted URL in the array and generate a unique key for it. then, store the URL in the text. of course, you can also store the URL in the database, this instance is stored in text.
?
Some functions:
?
1. array_search () function
?
Array_search (value, array, strict)
?
The array_search () function is the same as the in_array () function. you can find a key value in the array. If this value is found, the key name of the matching element is returned. If not found, false is returned.
?
2 .? Var_export ()? Function
?
?
This function returns the structure information about the variables passed to this function. it is similar to var_dump (). The difference is that the returned representation is legal PHP code.
You can set the second parameter of the function to TRUE to return the expression of the variable.
?
Compare var_export () and var_dump ().
?
?
?
What is the accept page? Redirect. php
?
?
?This page must be used in combination with. htaccess or. waccess
?
?
RewriteEngine On RewriteRule ^s=(.*)$ /redirect.php?uid=$1 [R=301,L]
??
?
?
Association:
Php creates short ID Create short IDs with PHP-Like Youtube or TinyURL??
?
If you have any questions, please leave a message ~
?
?