Skip to content

Commit 857855b

Browse files
committed
initial commit
0 parents  commit 857855b

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: jason_06tt1g7
5+
* Date: 3/5/2019
6+
* Time: 9:30 AM
7+
*/
8+
9+
require 'httpStatus.php';
10+
11+
$url = "https://google.com"; // url to test
12+
13+
$http = new \RedWebDev\httpStatus();
14+
15+
$status = $http->status($url);

httpStatus.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Created by ReddingWebDev.
4+
* User: Jason Olson
5+
* Date: 3/5/2019
6+
* Time: 9:28 AM
7+
*/
8+
9+
namespace RedWebDev;
10+
11+
12+
class httpStatus
13+
{
14+
function status($url) // only tlg sends correct error codes
15+
{
16+
$ch = curl_init();
17+
curl_setopt($ch, CURLOPT_URL, $url);
18+
curl_setopt($ch, CURLOPT_MAXREDIRS, 0); // can set to another number if you want to follow redirects
19+
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
20+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
21+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
22+
curl_setopt($ch, CURLOPT_NOBODY, true); // this speeds thing up by only returning the header data
23+
curl_exec($ch);
24+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
25+
curl_close($ch);
26+
return $status;
27+
}
28+
29+
}

0 commit comments

Comments
 (0)