Sample code for 30+ languages & platforms
PHP ActiveX

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$http = new COM("Chilkat.Http");
$http->KeepResponseBody = 1;

$sb = new COM("Chilkat.StringBuilder");
$success = $http->DownloadSb('https://chilkatsoft.com/testData/helloWorld.txt','utf-8',$sb);

$statusCode = $http->LastStatus;
if ($success == 0) {
    if ($statusCode == 0) {
        // Unable to either send the request or get the response.
        print $http->LastErrorText . "\n";
    }
    else {
        // We got a response, but the status code was not in the 200s
        print 'Response status code: ' . $statusCode . "\n";
        // Examine the response body.
        print 'Response body:' . "\n";
        print $http->LastResponseBody . "\n";
    }

    print 'Download failed.' . "\n";

}
else {
    print 'Download success, response status = ' . $statusCode . "\n";
    print $sb->getAsString() . "\n";
}


?>