Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 176 | | All time: 8,768 This week: 44 |
|
Description | | Author |
This class can access a page and return the HTTP status code.
It sends a HTTP request to a page with a given URL and retrieves the response.
The class returns the server response status code number so it is possible to determine if the page is available or not. | |
 |
|
Innovation award
 Nominee: 2x
Winner: 1x |
|
Recommendations
Example
<?php
/**
* Copyright (c) 2019. ReddingWebPro / Jason J. Olson, This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3
* of the License.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. You should have received a copy of the GNU General Public License along with this program. If not,
* see <https://www.gnu.org/licenses/>.
*/
/**
* Created by ReddingWebPro/ReddingWebDev
* User: Jason J. Olson
* License: GNU GPLv3
* GitHub: https://github.com/reddingwebpro/php-get-http-status
* Date: 3/6/2019
*/
require 'httpStatus.php';
$url = "https://google.com"; // url to test
$http = new \RedWebDev\httpStatus();
$status = $http->status($url);
|
Details
php-get-http-status
This class was designed in direct response to a forum post at PHPClasses for a class to test to find broken links on a given URL. This class will take a given URL and return the HTTP status code for that page. Therefore it will not only discover if the page is broken (ie 404), but also if its changes (ie 301 redirect) or good as is, (200). This will return the HTTP numerical values as defined in RFC 2616 section 10 (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
Configuration
In the example file you see we call the class, and we define the target URL as the variable $url. The data is returned as an integer value corresponding to the HTTP status code.
Requirements
This code requires the CURL library to be installed. This is extremely common to find, but if you're having problems, check by running phpinfo(); and checking that it is installed.
Revision History:
-
1.0 Initial Release
-
1.1 Minor code cleanup, formatting, new license
License
GNU General Public License v3.0 (GNU GPLv3)
http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.