473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Checking a url exists

Hi,

I've looked on this newsgroup on google and on php.net, but I can find
a work function which will allow me to check if a url exists?

Can anyone provide me with one?
or point we towards one?

Best regards,

Jules.

Jul 12 '06 #1
5 2251
I dont have code for this but you can do it fairly easily with sockets.
(see php docs)

1) create a socket resource
2) connect to the socket on port 80
3) send the URL
4) read the response.

Check for errors on each of the steps above
mindwarp wrote:
Hi,

I've looked on this newsgroup on google and on php.net, but I can find
a work function which will allow me to check if a url exists?

Can anyone provide me with one?
or point we towards one?

Best regards,

Jules.
Jul 12 '06 #2
Hi,

I've had a few attempts and always come up with a 200 return code.
I guess 404 handling pages are causing this.
Jules.

Jul 12 '06 #3
For example...

<?php

$url = 'http://www.whatever.com/ccc';

$fp = @fopen($url, 'r');

if ($fp) {

$headers = stream_get_meta_data($fp);

print_r($headers);
}

Jul 12 '06 #4
<comp.lang.php>
<mindwarp>
<12 Jul 2006 08:46:15 -0700>
<11**********************@35g2000cwc.googlegroups. com>
I've looked on this newsgroup on google and on php.net, but I can find
a work function which will allow me to check if a url exists?

Can anyone provide me with one?
or point we towards one?
$skunk="http://www.emailuser.co.uk";
if (fopen($skunk,'r')===FALSE) {exit;}

Although it doesnt work if the website uses a custom 404 webpage and i
never got around to doing any more work on it .
--
Encrypted email address
www.emailuser.co.uk/?name=KRUSTOV
Jul 12 '06 #5
hi,

yes, i want to cater for custom 404 pages

:(

Jules.

Jul 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bart Nessux | last post by:
Are these equivelent? Is one approach prefered over the other #check to see if var contains something... if so proceed. if var is not None: continue #check to see if var is empty... if so...
3
by: Phil Lamey | last post by:
Hi Folks, I have run into a bit of an issue with checking for files. Some files reside on Server X and some on Server Y. The page with all the links is on Server X. If the file exists we...
5
by: Richard L Rosenheim | last post by:
What's the proper technique for checking for the existence of an attribute within a node? Lets say I did a SelectSingleNode which returned this element: <AnAddress city="San Francisco"...
5
by: BerkshireGuy | last post by:
Hello everyone, I have a bond form that a user uses to enter data. One of my fields, is PolicyNumber. I added some code on the Before Update event of txtPolicyNumber that checks to see if...
15
by: Geiregat Jonas | last post by:
is using if(open("file",O_EXCL) != -1){ printf("File does exists")}else{printf("file does not exists"); } a good way of checking if a file exists or not, if not how should I do it ?
4
by: Darrel | last post by:
I'm trying to add an extra layer of error checking on a Drop Down List. The list is populated from one table, and then I select the selectedValue from another DB. While it SHOULDN'T ever happen,...
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
1
by: Edwina Rothschild | last post by:
Hello, I am new to PHP so I have done a research on how to check if an entry exists on the table. I came up with the following code: include("dbinfo.inc.php"); $Name=$_POST; $Code=$_POST;...
13
by: darkslide | last post by:
Hi, I'm checking if a file exists with the following code; If System.IO.File.Exists("C:\test.txt") = True Then MsgBox("File Exists") Else MsgBox("File Does Not Exist") End If ...
7
by: sprash | last post by:
Newbie question: I'm trying to determine if a file physically exists regardless of the permissions on it Using File.Exists() returns false if it physically exists but the process does not...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.