BaiduBCS::format_url PHP Méthode

format_url() private méthode

构造url
private format_url ( array $opt ) : boolean | string
$opt array
Résultat boolean | string
    private function format_url($opt)
    {
        $sign = $this->format_signature($opt);
        if ($sign === false) {
            trigger_error("Format signature failed, please check!");
            return false;
        }
        $opt['sign'] = $sign;
        $url = "";
        $url .= $this->use_ssl ? 'https://' : 'http://';
        $url .= $this->hostname;
        $url .= '/' . $opt[self::BUCKET];
        if (isset($opt[self::OBJECT]) && '/' !== $opt[self::OBJECT]) {
            $url .= "/" . rawurlencode($opt[self::OBJECT]);
        }
        $url .= '?' . $sign;
        if (isset($opt[self::QUERY_STRING])) {
            foreach ($opt[self::QUERY_STRING] as $key => $value) {
                $url .= '&' . $key . '=' . $value;
            }
        }
        return $url;
    }