Skip to content

Instantly share code, notes, and snippets.

@yujp
Created March 22, 2026 12:25
Show Gist options
  • Select an option

  • Save yujp/e580e8fb01d885d5cb366fd9ddb8ed88 to your computer and use it in GitHub Desktop.

Select an option

Save yujp/e580e8fb01d885d5cb366fd9ddb8ed88 to your computer and use it in GitHub Desktop.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
$result = curl_exec($ch);
$code = $result ? curl_getinfo($ch, CURLINFO_RESPONSE_CODE): null;
curl_close($ch);
$ok = is_int($code) && 200 <= $code && $code < 300;
http_response_code($ok ? 200: 502);
echo json_encode(['ok' => $ok, 'code' => $code]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment