Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2004, 06:31 PM
Authorized User
 
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check url is live

I want to check that a particular url or ip address is actually live before linking to that site.
What code would I need to do this?
Thanks
 
Old August 16th, 2004, 06:34 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't think this is possible with PHP.

I'll let you know if I think up anything, though.

Snib

<><
 
Old August 16th, 2004, 06:36 PM
Authorized User
 
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can it be done in any otehr way?

 
Old August 16th, 2004, 08:00 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

What you are talking about is called a ping command.

There are a couple of ways to go about it from PHP. The most obvious is to execute a command line ping and this is done differently depending on your OS.

I would suggest having a look at the PEAR Net_Ping package, which provides all of the different commands that different operating systems provide for pinging a location in one object.

http://pear.php.net/Net_Ping

HTH!


Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old August 16th, 2004, 08:11 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

You can also write a simple test script...

Code:
<pre>
<?php
    echo shell_exec('ping http://p2p.wrox.com');
?>
</pre>
-or-

Code:
<pre>
<?php
    echo `ping http://p2p.wrox.com`;
?>
</pre>
Using the backtick operator is identical to the shell_exec function.

That's the Windows ping. You'll see exactly the same output here as you would by pinging the domain at the command line.


Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail





Similar Threads
Thread Thread Starter Forum Replies Last Post
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
Connect to VSS check-in Check-out Programatically rhd110 General .NET 6 August 12th, 2007 07:46 AM
Live Search? Ashleek007 Ajax 1 June 4th, 2007 01:25 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
LIVE RADIO theokrtz Classic ASP Professional 1 August 24th, 2004 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.