LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2004, 12:40 PM   #1
digitalgravy
Member
 
Registered: Nov 2003
Posts: 86

Rep: Reputation: 15
Can you verify a url with php?


I am trying to re-create an ASP script I found, but I am having trouble with it.

I am trying to verify if a file exists on a remote web server. Specifically a favicon.ico file.

In the ASP script it uses a function called HttpExists() and I can't seem to find an equivalent in php. I tried file_exists() but that does not work.

Is there a way to verify a url to see if it is a valid document?

Thanks
 
Old 03-01-2004, 01:06 PM   #2
elitecodex
Member
 
Registered: Feb 2004
Location: MD
Distribution: Fedora 9
Posts: 129

Rep: Reputation: 15
My PHP might be a little rusty, so it might need some tweaking... but this should work

Code:
<?php
    if ( @fopen("http://www.domain.com/favicon.ico") )
        echo "Its there!!";
    else
        echo "sorry...";
?>
Double check the fopen function as I dont use to much File IO but that should work
http://www.php.net/fopen
 
Old 03-01-2004, 01:19 PM   #3
digitalgravy
Member
 
Registered: Nov 2003
Posts: 86

Original Poster
Rep: Reputation: 15
Thanks elitecodex,

You sent me in the right direction. At first it did'nt work, but then I reviewed the php manual for that function and added the "r" option for read only mode and it works. Thanks, Ill post a link to the final product when I'm done.

Thanks again!
 
Old 03-01-2004, 01:33 PM   #4
elitecodex
Member
 
Registered: Feb 2004
Location: MD
Distribution: Fedora 9
Posts: 129

Rep: Reputation: 15
ahh... forgot about that!! thats what i get for not using file i/o that much

oh well... at least i helped solve your problem
 
Old 03-01-2004, 01:38 PM   #5
digitalgravy
Member
 
Registered: Nov 2003
Posts: 86

Original Poster
Rep: Reputation: 15
Thanks again!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing URL in PHP benrose111488 Programming 6 10-12-2005 12:12 PM
how to use php open and url antony_csf Programming 7 09-27-2004 12:54 AM
Getting the url with PHP linux_pioneer Linux - General 2 06-20-2004 02:08 PM
PHP Url? HappyDude Programming 2 09-20-2003 04:20 PM
PHP Session -- Url contains ?<NAME>=<ID> tomgun6 Programming 0 03-02-2003 11:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration