load() Function for PHP - Fetch URL Content

reference: http://www.bin-co.com/php/scripts/load/

* usage:

RETURN = load(URL, OPTIONS);

RETURN: (Array, String)

if ($options['return_info'] == true)

RETURN_TYPE is Array[Header, Body, Info]

else

RETURN_TYPE is String[Body]

URL: (String)

example: normal url or uri

OPTION: (Array)

is like $default_options

* default options:

$default_options = array(
        
'method'        => 'get',
        
'post_data'        => false,
        
'return_info'    => false,
        
'return_body'    => true,
        
'cache'            => false,
        
'referer'        => '',
        
'headers'        => array(),
        
'session'        => false,
        
'session_close'    => false,
    );

* examples:

1st:

$contents = load('http://example.com/rss.xml');

2nd:

$options = array(
    'return_info'   => true,
    'method'                => 'post'
);
$result = load('http://www.bin-co.com/rss.xml.php?section=2',$options);
print_r($result);

The output will be like this...

Array
(
    [headers] => Array
        (
            [Date] => Mon, 18 Jun 2007 13:56:22 GMT
            [Server] => Apache/2.0.54 (Unix) PHP/4.4.7 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
            [X-Powered-By] => PHP/5.2.2
            [Expires] => Thu, 19 Nov 1981 08:52:00 GMT
            [Cache-Control] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
            [Pragma] => no-cache
            [Set-Cookie] => PHPSESSID=85g9n1i320ao08kp5tmmneohm1; path=/
            [Last-Modified] => Tue, 30 Nov 1999 00:00:00 GMT
            [Vary] => Accept-Encoding
            [Transfer-Encoding] => chunked
            [Content-Type] => text/xml
        )
    [body] => ... Contents of the Page ...
    [info] => Array
        (
            [url] => http://www.bin-co.com/rss.xml.php?section=2
            [content_type] => text/xml
            [http_code] => 200
            [header_size] => 501
            [request_size] => 146
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 1.113792
            [namelookup_time] => 0.180019
            [connect_time] => 0.467973
            [pretransfer_time] => 0.468035
            [size_upload] => 0
            [size_download] => 2274
            [speed_download] => 2041
            [speed_upload] => 0
            [download_content_length] => 0
            [upload_content_length] => 0
            [starttransfer_time] => 0.826031
            [redirect_time] => 0
        )
)

* Code:

please visite http://www.bin-co.com/php/scripts/load/

comment(hidden)

膩撐 發表在 痞客邦 留言(0) 人氣()

reference:http://www.codingforums.com/showthread.php?t=20922

http://ant4js.blogspot.com/2008/12/function.html

function dispatcher()

{

switch(arguments.length)

{

case 1:real1(arguments[0]);break;

case 2:real2(arguments[0],arguments[1]);break;

case 3:real3(arguments[0],arguments[1],arguments[2]);break;

}

}

 

function real3(a,b,c)

{

alert(a+'-'+b+'-'+c);

}

 

function real2(a,b)

{

alert(a+'-'+b);

 

}

<button  onClick="dispatcher('a','b')">Test</button>
<button  onClick="dispatcher('a')">Test</button>
<button  onClick="dispatcher('a','b','c')">Test</button>

膩撐 發表在 痞客邦 留言(0) 人氣()

螞蟻的 JAVASCRIPT

http://ant4js.blogspot.com/

W3schools 各式各樣教學網站 (網路上有山寨中文版,請自行蒐尋)

http://www.w3schools.com/js/default.asp

Simplify Ajax development with jQuery (IBM網站其中一篇)

  http://www.ibm.com/developerworks/library/x-ajaxjquery.html

 

膩撐 發表在 痞客邦 留言(0) 人氣()