Sample code for 30+ languages & platforms
PHP

Example: Http.QuickGetStr method

Demonstrates the QuickGetStr method.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Http;

$http = new Http();

// Keep the response body if there's an error.
$http->KeepResponseBody = true;

// Send the HTTP GET and return the content in a string.
try {
    $str = $http->QuickGetStr('https://www.chilkatsoft.com/helloWorld.json');
} catch (\Chilkat2\Exception $e) {
    if ($http->LastStatus == 0) {
        // Communications error.  We did not get a response.
        echo $e->getMessage(), "\n";
    } else {
        echo 'Response status code: ', $http->LastStatus, "\n";
        echo "Response body error text:\n";
        echo $http->LastResponseBody, "\n";
    }

    exit;
}

echo $str, "\n";
echo "Success\n";