Hi,
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
Thanks! 5 1117
On 13 Nov, 11:00, AK <danr...@gmail.comwrote:
Hi,
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
Thanks!
Try typing
php http request
into Google
On Nov 13, 8:00 am, AK <danr...@gmail.comwrote:
Hi,
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
Thanks!
Perhaps this could help http://ar.php.net/manual/en/function.fopen.php#58099
On Nov 13, 12:00 pm, AK <danr...@gmail.comwrote:
....
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
<?php
file_get_contents("http://google.com");
var_dump($http_response_header);
?>
Csaba Gabor from Vienna
On Nov 14, 12:09 am, Csaba Gabor <dans...@gmail.comwrote:
On Nov 13, 12:00 pm, AK <danr...@gmail.comwrote:
...
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
<?php
file_get_contents("http://google.com");
var_dump($http_response_header);
?>
Csaba Gabor from Vienna
Thanks, that's the sort of "quick solution" I was looking for
(although I managed to find it myself after a bit of digging:
$arr = get_headers("http://www.google.com");
is even more concise)
Thanks to the previous responses as well, including the one that
suggested using a quaint little thing that seems to have the amazing
ability to search through web pages! (Google, I think it's called... )
Cheers
In our last episode,
<11*********************@k79g2000hse.googlegroups. com>,
the lovely and talented AK
broadcast on comp.lang.php:
Hi,
Can anyone tell me how to connect to a URL using PHP for the purpose
of obtaining the HTTP response code? Specifically, I want to be able
to ascertain whether a link is down (404) or alive.
A bare-bones example would be appreciated.
Thanks!
Is there some reason searching the manual index on 'http' did not turn up
http_head for you?
--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 432 days to go.
What do you do when you're debranded? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paris_Sucks |
last post by:
I'm trying to redirect when testing for certain condidtions as shown
below. When the conditions are ture, it redirects, but still goes ahead and
processes the sql query. What am I doing wrong??? ...
|
by: Walter Dörwald |
last post by:
Hello all!
I'm trying to parse broken HTML with several Python tools.
Unfortunately none of them work 100% reliable. Problems are
e.g. nested comments, bare "&" in URLs and "<" in text (e.g....
|
by: Josef Meile |
last post by:
Hi,
I'm trying to do a simple link checking for python 2.1.3 (compiled from
source on linux), but it fails when I use an invalid ssl url. For
example: I have zope without ssl running on port...
|
by: Steven T. Hatton |
last post by:
Some people have suggested the desire for code completion and refined
edit-time error detection are an indication of incompetence on the part of
the programmer who wants such features. ...
|
by: Christopher Benson-Manica |
last post by:
All right, since my previous idea (calling functions through a
wrapper) was apparently so awful no one could suggest any
improvements, I'll try a different tack. My end goal is to make
detecting...
|
by: Michael B Allen |
last post by:
I have a general purpose library that has a lot of checks for bad input
parameters like:
void *
linkedlist_get(struct linkedlist *l, unsigned int idx)
{
if (l == NULL) {
errno = EINVAL;...
|
by: Dave |
last post by:
Is it difficult to write a program that, given an array of URLs, will probe
each one, and return a status of Found or Not Found? How would you approach
it?
While Googling, I found utility after...
|
by: Dave |
last post by:
Hello All,
A couple of weeks ago, I undertook to write a utility that would loop
through various URLs and test whether they were valid. I got some good help
from this list, and was able to...
|
by: Steve |
last post by:
Hi Guys;
You have been giving me a lot of useful information in the other two
threads. Thanks! Very interesting.
Here is my situation. My friend is writing a book. He has 3100
citations,...
|
by: rpupkin77 |
last post by:
Hi,
I have written this script to run as a cron that will loop through a
text file with a list of urls. It works fine for most of the links,
however there are a number of urls which are...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |