Heim > Backend-Entwicklung > PHP-Tutorial > 仿微博php生成短网址,仿微博php_PHP教程

仿微博php生成短网址,仿微博php_PHP教程

WBOY
Freigeben: 2016-07-12 08:51:04
Original
963 Leute haben es durchsucht

仿微博php生成短网址,仿微博php

html code

<span><!</span><span>DOCTYPE html</span><span>></span>  
<span><</span><span>html </span><span>lang</span><span>="en"</span><span>></span>  
<span><</span><span>head</span><span>></span>  
  <span><</span><span>meta </span><span>charset</span><span>="utf-8"</span> <span>/></span>  
  <span><</span><span>title</span><span>></span>urlShort<span></</span><span>title</span><span>></span>  
<span></</span><span>head</span><span>></span>  
  
<span><</span><span>body</span><span>></span>  
  <span><</span><span>form </span><span>action</span><span>="urlShort.php"</span><span> method</span><span>="post"</span><span>></span>  
    <span><</span><span>input </span><span>type</span><span>="text"</span><span> size</span><span>="16"</span><span> name</span><span>="url"</span><span> value</span><span>="输入网址"</span><span> onfocus</span><span>="if(this.value=='输入网址'){this.value='';}"</span><span> onblur</span><span>="if(this.value==''){this.value='输入网址'};"</span><span>></span>  
    <span><</span><span>input </span><span>type</span><span>="submit"</span><span> value</span><span>=" 生成 "</span> <span>/></span>  
  <span></</span><span>form</span><span>></span>  <span><</span><span>a </span><span>href</span><span>="http://hovertree.com"</span><span>></span>何问起<span></</span><span>a</span><span>></span>
<span></</span><span>body</span><span>></span>  
<span></</span><span>html</span><span>></span>  
Nach dem Login kopieren

php code

<?<span>php  
     </span><span>header</span>("Content-Type:text/html;charset=UTF-8"<span>);    
     </span><span>function</span> base62(<span>$x</span><span>){  
        </span><span>$show</span> = ''<span>;  
        </span><span>while</span>(<span>$x</span>>0<span>){  
            </span><span>$s</span> = <span>$x</span> % 62<span>;  
            </span><span>if</span> (<span>$s</span> > 35<span>){  
                </span><span>$s</span> = <span>chr</span>(<span>$s</span> + 61<span>);  
            }</span><span>else</span> <span>if</span> (<span>$s</span> > 5 && <span>$S</span><=35<span>){  
                </span><span>$s</span> = <span>chr</span>(<span>$s</span> + 55<span>);  
            }  
            </span><span>$show</span> .= <span>$s</span><span>;  
            </span><span>$x</span> = <span>floor</span>(<span>$x</span>/62<span>);  
        }  
        </span><span>return</span> <span>$show</span><span>;  
    }  </span><span>/*</span><span> 何问起 hovertree.com </span><span>*/</span>
      
    <span>function</span> url_short(<span>$url</span><span>){  
        </span><span>$url</span> = <span>crc32</span>(<span>$url</span><span>);  
        </span><span>$result</span> = <span>sprintf</span>("%u",<span>$url</span><span>);   
        </span><span>return</span> base62(<span>$result</span><span>);  
    }  
      
    </span><span>echo</span> ("生成的新网址为:<a href='http://<span>$_POST</span>[url]'>".url_short(<span>$_POST</span>['url'])."</a>"<span>);  
</span>?>
Nach dem Login kopieren

推荐:http://www.cnblogs.com/roucheng/p/3528396.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1132464.htmlTechArticle仿微博php生成短网址,仿微博php html code ! DOCTYPE html html lang ="en" head meta charset ="utf-8" / title urlShort / title / head body form action ="urlShort.php" meth...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage