Utils.php 1.08 KB
<?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;
    }

}