public static
hQuery
|
#
fromHTML( string $html, string $url = NULL )
Parse and HTML string.
Parameters
- $html
- source of some HTML document
- $url
- OPTIONAL location of the document. Used for relative URLs inside the document.
Returns
|
public static
hQuery
|
#
fromFile( string $filename, boolean $use_include_path = false, resource $context = NULL )
Read the HTML document from a file.
Read the HTML document from a file.
Parameters
- $filename
- $use_include_path
- OPTIONAL passed to file_get_contents()
- $context
- OPTIONAL A valid context resource created with stream_context_create().
Returns
|
public static
hQuery
|
#
fromURL( string $url, array $headers = NULL, array|string $body = NULL, array $options = NULL )
Fetch the HTML document from remote $url.
Fetch the HTML document from remote $url.
Parameters
- $url
- $headers
- $body
- OPTIONAL body of the request (for POST or PUT)
- $options
- OPTIONAL request options (see self::http_wr() for more details)
Returns
|
public
hQuery_Element
|
#
find( string $sel, array|string $attr = NULL, hQuery_Node $ctx = NULL )
Finds a collection of nodes inside current document/context (similar to jQuery.fn.find()).
Finds a collection of nodes inside current document/context (similar to jQuery.fn.find()).
Parameters
- $sel
- $attr
- OPTIONAL attributes as string or key-value pairs.
- $ctx
- OPTIONAL the context where to search. If omitted, $this is used.
Returns
Overrides
|
public
array
|
#
find_html( string $sel, array|string $attr = NULL, hQuery_Node $ctx = NULL )
Combination of ->find() + ->html()
Combination of ->find() + ->html()
Parameters
- $sel
- $attr
- OPTIONAL attributes as string or key-value pairs.
- $ctx
- OPTIONAL the context where to search. If omitted, $this is used.
Returns
array list of HTML contents of all matched elements
|
public
array
|
#
find_text( string $sel, array|string $attr = NULL, hQuery_Node $ctx = NULL )
Combination of ->find() + ->text()
Combination of ->find() + ->text()
Parameters
- $sel
- $attr
- OPTIONAL attributes as string or key-value pairs.
- $ctx
- OPTIONAL the context where to search. If omitted, $this is used.
Returns
array list of Text contents of all matched elements
|
public
|
#
index( )
Index elements of the source HTML. (Called automatically)
Index elements of the source HTML. (Called automatically)
|
public static
string
|
#
jsonize( mixed $data, &string & $type = NULL, $ops = 0 )
Serialize $data as JSON, fallback to serialize.
Serialize $data as JSON, fallback to serialize.
Parameters
- $data
- the data to be serialized
- $type
- returns the serialization method used ('json' | 'ser')
- $ops
Returns
string the serialized data
|
public static
mixed
|
#
unjsonize( string $str, &string & $type = NULL )
Unserialize $data from either JSON or serialize.
Unserialize $data from either JSON or serialize.
Parameters
- $str
- the data to be unserialized
- $type
- if not set, returns the serialization method detected ('json' | 'ser');
if set, forces unjsonize() to use this method for unserialization.
Returns
mixed the unserialized data
|
protected static
string
|
#
serjstype( string $str )
Tries to detect format of $str (json or ser).
Tries to detect format of $str (json or ser).
Parameters
- $str
- JSON encoded or PHP serialized data.
Returns
string 'json' | 'ser', or FALSE on failure to detect format.
|
public static
|
#
gzdecode( $str )
gzdecode() (for PHP < 5.4.0)
gzdecode() (for PHP < 5.4.0)
|
protected static
|
#
_gzdecode( $data )
Alternative gzdecode() (for PHP < 5.4.0)
source: http://nl1.php.net/manual/en/function.gzdecode.php#82879
Alternative gzdecode() (for PHP < 5.4.0)
source: http://nl1.php.net/manual/en/function.gzdecode.php#82879
|
protected static
array
|
#
get_cache( string $fn, integer $expire = false, boolean $meta_only = false )
Read data from a cache file.
Read data from a cache file.
Parameters
- $fn
- $expire
- OPTIONAL contents returned only if it is newer then $expire seconds
- $meta_only
- OPTIONAL if TRUE, read only meta-info (faster)
Returns
array [mixed , array ]
|
protected static
integer|boolean
|
#
set_cache( string $fn, mixed $cnt, array $meta = NULL, boolean $gzip = true )
Save data to a cache file.
Save data to a cache file.
Parameters
- $fn
- $cnt
- $meta
- OPTIONAL meta information related to contents.
- $gzip
- OPTIONAL if TRUE and gzip supported, store contents gzipped
Returns
integer|boolean On success, number of written bytes, FALSE on fail.
|
public static
true
|
#
do_flock( resource $fp, integer $lock, integer $timeout_ms = 384 )
Lock with retries
Parameters
- $fp
- $lock
- $timeout_ms
- OPTIONAL Timeout to wait for unlock in miliseconds
Returns
true on success, false on fail
Author
Dumitru Uzun
|
public static
|
|
public static
|
|
public static
boolean
|
#
is_url_path( string $path )
Check whether $path is a valid url.
Check whether $path is a valid url.
Parameters
Returns
boolean TRUE if $path is a valid URL, FALSE otherwise
|
public static
boolean
|
#
is_abs_path( string $path )
Check whether $path is an absolute path.
Check whether $path is an absolute path.
Parameters
Returns
boolean TRUE if $path is an absolute path, FALSE otherwise
|
public static
string
|
#
abs_url( string $url, string $base )
Given a $url (relative or absolute) and a $base url, returns absolute url for $url.
Given a $url (relative or absolute) and a $base url, returns absolute url for $url.
Parameters
Returns
string absolute URL for $url
|
public static
|
|
public static
array
|
#
http_wr( string $host, array $head = NULL, mixed $body = NULL, array $options = NULL )
Executes a HTTP write-read session.
Executes a HTTP write-read session.
Parameters
- $host
- $head
- list off HTTP headers to be sent along with the request to $host
- $body
- data to be sent as the contents of the request. If is array or object, a http query is built.
- $options
- list of option as key-value:
timeout - connection timeout in seconds
host - goes to headers, overrides $host (ex. $host == '127.0.0.1', $options['host'] == 'www.example.com')
port - useful when $host is not a full URL
scheme - http, ssl, tls, udp, ...
close - whether to close connection o not
redirects - number of allowed redirects
redirect_method - if (string), this is the new method for redirect request, else
if true, preserve method, else use 'GET' on redirect.
by default preserve on 307 and 308, GET on 301-303
Returns
array [contents, headers, http-status-code, http-status-message]
Author
Dumitru Uzun
|