SimplePie_IRI::set_authority PHP Method

set_authority() public method

Set the authority. Returns true on success, false on failure (if there are any invalid characters).
public set_authority ( string $authority ) : boolean
$authority string
return boolean
    function set_authority($authority)
    {
        if (($userinfo_end = strrpos($authority, '@')) !== false) {
            $userinfo = substr($authority, 0, $userinfo_end);
            $authority = substr($authority, $userinfo_end + 1);
        } else {
            $userinfo = null;
        }
        if (($port_start = strpos($authority, ':')) !== false) {
            $port = substr($authority, $port_start + 1);
            $authority = substr($authority, 0, $port_start);
        } else {
            $port = null;
        }
        return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port);
    }

Usage Example

Esempio n. 1
0
 public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
 {
     $iri = new SimplePie_IRI('');
     $iri->set_scheme($scheme);
     $iri->set_authority($authority);
     $iri->set_path($path);
     $iri->set_query($query);
     $iri->set_fragment($fragment);
     return $iri->get_iri();
 }