Utils.php
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Created by PhpStorm.
* User: ziy
* Date: 14-7-7
* Time: 下午7:46
*/
class YHMCart_Library_Utils
{
/**
* 金额格式化
* @param $number
* @param int $decimals
* @return string
*/
static function formatCurrency($number, $decimals = 2)
{
return number_format($number, $decimals, '.', '');
}
/**
* 远程获取数据,POST模式
* @param $url
* @param $parameter
* @param array $opt
* @return YHMCart_Library_Http
*/
static function post($url, $parameter, array $opt = array())
{
$response = new YHMCart_Library_Http($url, $opt);
$response->setParameterPost($parameter);
$response->request('POST');
return $response;
}
/**
* 远程获取数据,GET模式 & 远程输出的数据
* @param $url
* @param $cacert_url
* @return YHMCart_Library_Http
*/
static function get($url, array $opt = array())
{
$response = new YHMCart_Library_Http($url, $opt);
$response->request();
return $response;
}
}