php c扩展实现的url短链接生成,php extentsion short_link
在此要特别感谢,香蕉和fermi的用心指导
安装方法 install
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
使用方法
$url = "http://www.abc.om/def/ghi.php"; $pre_url = "http://a.cn"; $arr = shorlink($url); $short_url = $pre_url.$arr[0]; $arr类似下面的数组,返回4个可用的短链,随便取一个即可。 array(4) { [0]=> string(6) "9Syv1C" [1]=> string(6) "Tyb5GO" [2]=> string(6) "a5eDi1" [3]=> string(6) "1C0W9S" }
根据以下php算法改写的 c生成php扩展,在性能提升了3倍。
> 5; } $short_url_list[] = $short_url; } return $short_url_list; } } $url = "http://www.cnblogs.com/zemliu/"; $short = Short_Url::short($url); print_r($short); ?>