Hi,
Please help me if anybody can,
I am using header('Location:$host') to redirect now how can I determine first that wheather the $host is live or not?Is there any way to redirect to a custom failure page if $host is not accesible?
Help..How to find a host live or not before using header()
Moderator: General Moderators
-
anirbanb2004
- Forum Newbie
- Posts: 23
- Joined: Sun Oct 15, 2006 4:21 pm
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
Code: Select all
if(isset($host))
{
//blah
}
else
{
// other bah
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I think you're referring to determining if the address is physically accessible. Use:
Code: Select all
if ($sock = fsockopen($host, 80, 10, $errno, $errstr))
{
fclose($sock);
//ok
}-
anirbanb2004
- Forum Newbie
- Posts: 23
- Joined: Sun Oct 15, 2006 4:21 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Think really hard about that question... errno (error number perhaps) and errstr (error string, message, perhaps)...
The manual has a great deal of information about how functions work.
The manual has a great deal of information about how functions work.
Last edited by RobertGonzalez on Tue Apr 17, 2007 1:29 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
anirbanb2004
- Forum Newbie
- Posts: 23
- Joined: Sun Oct 15, 2006 4:21 pm
Code doesn't run better to say perhaps I couldn't make it use.I am to check address like http://59.93.193.52:8080 is alive or not.