Results: 133
number_format
The default
thousands_separator
is
,
which is 4th parameter. Without passing something else for the
thousands_separator
parameter, the
latency
was equal to
1,511.68525
The following PHP code caused problem in MySQL
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5);
MySQL error:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'latency' at row 1
Solution to the problem is to specify the 4th parameter as an empty string
""
to get
latency
equal to
1511.68525
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5, '.', '');
Basic authentication
Postman request
Authorization type: Basic Auth
Username: usr
Password: pwd
PHP cURL request
curl_setopt($ch, CURLOPT_USERPWD, "usr:pwd");
file_get_contents timeout
Default
time limit
for
file_get_contents
is 60 seconds which we can increase using
timeout
property of
http
object
$opts = [
    "http" => [
        "method" => "GET",
        "timeout"=> 1200,
        "header" => 
            "Channel-Name: ".CHANNEL."\r\n" .
            "Authorization: ".AUTHORIZATION."\r\n"
    ]
];
// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
$context = stream_context_create($opts); //, false, $context

$startTime = microtime(1);
$res = file_get_contents($url . $query, false, $context);
Results: 133