Home > Backend Development > PHP Tutorial > 征集常用的PHP简单代码

征集常用的PHP简单代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:27:19
Original
983 people have browsed it

收集常用的PHP简单代码

对于日常工作中整理出来的某些功能做个简单梳理:

?

1. 短链生成算法

function code62($x) {	$show = '';	while($x > 0) {		$s = $x % 62;		if ($s > 35) {			$s = chr($s+61);		} elseif ($s > 9 && $s <=35) {			$s = chr($s + 55);		}		$show .= $s;		$x = floor($x/62);	}	return $show;}  function shorturl($url) {	$url = crc32($url);	$result = sprintf("%u", $url);	//return $url;	//return $result;	return code62($result);}br( shorturl("http://pai.game.weibo.com/love/") );br( shorturl("http://www.oschina.net/code/snippet_878945_22499") );
Copy after login

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Return value problem
From 1970-01-01 08:00:00
0
0
0
Return JSON response via PHP
From 1970-01-01 08:00:00
0
0
0
Usage of return
From 1970-01-01 08:00:00
0
0
0
Why not return data in json format?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template