Overview
  • Namespace
  • Class

Namespaces

  • Hug
    • Http

Classes

  • Http

Class Http

Namespace: Hug\Http
Located at Hug/Http/Http.php

Methods summary

public static string|null
# nslookup( string $url )

Execute shell nslookup command

Execute shell nslookup command

This function is used to accelerate Domain Name Availability : if a domain name responds to nslookup command then it's not available for purchase !

Parameters

$url

Returns

string|null
Url corresponding IP address or null
public static boolean
# is_url_accessible( string $url )

Check if an url is accessible (means not a 404)

Check if an url is accessible (means not a 404)

Parameters

$url

Returns

boolean
is_url_accessible
public static integer
# get_http_code( string $url )

Returns HTTP code for given URL

Returns HTTP code for given URL

Parameters

$url
$utl

Returns

integer
HTTP code
public static string
# url_remove_query( string $url )

Cleans an url from its query parameters

Cleans an url from its query parameters

Example : input : http://www.monsite.fr/fr/coucou/index.php?id=3&num=50 output : http://www.monsite.fr/fr/coucou/index.php

Parameters

$url

Returns

string
$clean_url
public static string
# url_remove_query_and_path( string $url )

Cleans an url from its query parameters and path

Cleans an url from its query parameters and path

Example : input : http://www.monsite.fr/fr/coucou/index.php?id=3&num=50 output : http://www.monsite.fr

Parameters

$url

Returns

string
$clean_url
public static boolean
# grab_image( string $url, string $save_to )

Quick and dirty function to save an image (or any binary data transfered by url) from the internet

Quick and dirty function to save an image (or any binary data transfered by url) from the internet

http://stackoverflow.com/questions/6476212/save-image-from-url-with-curl-php

Parameters

$url
$save_to

Returns

boolean
public static array
# get_default_headers( strnig $host )

Returns basic HTTP headers for a CURL request

Returns basic HTTP headers for a CURL request

Parameters

$host
(ex: www.google.fr)

Returns

array
$headers (Connection, Accept, Accept-Charset, Keep-Alive, Accept-Language, Host)
public static string
# extract_tld_from_url( string $url )

Extracts a TLD (Top Level Domain) from an URL

Extracts a TLD (Top Level Domain) from an URL

Parameters

$url

Returns

string
$tld
public static string
# extract_domain_from_url( string $url )

In PHP : http://w-shadow.com/blog/2012/08/28/tldextract/ In nodejs : https://github.com/oncletom/tld.js

In PHP : http://w-shadow.com/blog/2012/08/28/tldextract/ In nodejs : https://github.com/oncletom/tld.js

Parameters

$url

Returns

string
$domain
public static string
# extract_subdomain_from_url( string $url )

Extracts a sub-domain from an URL

Extracts a sub-domain from an URL

Parameters

$url

Returns

string
$tld
public static
# extract_request_headers_body( $html_with_headers )
public static boolean
# header_status( integer $statusCode )

Sets a php script desired status code (usefull for API)

Sets a php script desired status code (usefull for API)

Parameters

$statusCode
$status_code

Returns

boolean
$response Has header status been set or not

Link

http://stackoverflow.com/questions/4162223/how-to-send-500-internal-server-error-error-from-a-php-script
public static string
# get_redirect_url( string $url )

Gets the address that the provided URL redirects to, or false if there's no redirect.

Gets the address that the provided URL redirects to, or false if there's no redirect.

Parameters

$url

Returns

string

Link

http://stackoverflow.com/questions/3799134/how-to-get-final-url-after-following-http-redirections-in-pure-php
public static array
# get_all_redirects( string $url )

get_all_redirects() Follows and collects all redirects, in order, for the given URL.

get_all_redirects() Follows and collects all redirects, in order, for the given URL.

Parameters

$url

Returns

array
public static string
# get_final_url( string $url )

get_final_url() Gets the address that the URL ultimately leads to. Returns $url itself if it isn't a redirect.

get_final_url() Gets the address that the URL ultimately leads to. Returns $url itself if it isn't a redirect.

Parameters

$url

Returns

string
API documentation generated by ApiGen