Skip to content

Instantly share code, notes, and snippets.

View chuanxd's full-sized avatar

Timmy Chang chuanxd

View GitHub Profile
@chuanxd
chuanxd / curl_example.php
Created May 14, 2016 03:40 — forked from carbontwelve/curl_example.php
PHP Curl to check if url is alive
<?php
function check_alive($url, $timeout = 10, $successOn = array(200, 301)) {
$ch = curl_init($url);
// Set request options
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_NOBODY => true,
CURLOPT_TIMEOUT => $timeout,