netliva/helpers

Netliva 辅助类

v0.1.0 2018-11-20 07:34 UTC

This package is auto-updated.

Last update: 2024-09-29 03:52:46 UTC


README

此包为项目提供辅助

安装

打开命令控制台,进入您的项目目录并执行

$ composer require netliva/helpers

基本用法

使用三位字符的货币代码获取货币符号

<?php
//...

$currency_symbols = new Netliva\Helper\CurrencySymbols();
echo  $currency_symbols->get("TRY")
// output: ₺

//...
?>

获取用户地理位置信息

<?php
//...

$ip_geo_helper = new Netliva\Helper\IpGeo();
echo $ip_geo_helper->getIp();
// output: "123.123.123.123" (ip of your)
echo $ip_geo_helper->getInfo("city");
// output: "Izmir" (city of your location)
 
//...
?>

支持的目的包括 "country", "country_code", "state", "region", "city", "address", "currency_code", "currency_symbol", "currency_converter"

获取IP地理位置信息

<?php
//...

$ip_geo_helper = new Netliva\Helper\IpGeo();
$ip_geo_helper->setIp("172.217.168.238");
echo $ip_geo_helper->getInfo("country");
// output: "United States" (country of google ip location)
 
//...
?>

获取所有目的

<?php
//...

$ip_geo_helper = new Netliva\Helper\IpGeo();
echo $ip_geo_helper->getInfo();
/*
 * output:
 * 
 * Array
 * (
 *	 [ip] => 123.123.123.123
 *	 [city] => Izmir
 *	 [state] => Izmir
 *	 [country] => Turkey
 *	 [country_code] => TR
 *	 [continent] => Asia
 *	 [continent_code] => AS
 *	 [currency_code] => TRY
 *	 [currency_symbol] => YTL
 *	 [currency_converter] => 5.4604
 * )
 */
 
//...
?>