Alternative to fopen() to see if a remote file exists
Posted: Thu Aug 25, 2005 4:25 pm
Hello 
I'm currently working on a script for a theatre company which has cast lists on their pages about each of their productions. They are connected with an acting agency and want the cast lists to link to each member's profile on the agency website. Each profile is on its own page and named logically so I can work out, given the person's first name and surname, what the address of the page on the agency website should be. This would be simple if all members of the company had profile pages with that agency. Some do not.
Therefore, I need to have a way to test if that member has a profile on the agency's website, hosted elsewhere, and provide a link to their profile if they do and not if not. I know I can use fopen() and test on the return value of that, but I find with some of the larger cast lists its taking a while to generate the pages. Ideally I need a way to just test to see if the page exists on the other server and not actually download the whole thing each time.
I know that file_exists() works with URL wrappers in PHP5, but that's not much help in this situation (the server is running PHP4). I wondered if anyone else had any bright ideas on ways it could be done which might be a little quicker
Cheers,
Jonathon
I'm currently working on a script for a theatre company which has cast lists on their pages about each of their productions. They are connected with an acting agency and want the cast lists to link to each member's profile on the agency website. Each profile is on its own page and named logically so I can work out, given the person's first name and surname, what the address of the page on the agency website should be. This would be simple if all members of the company had profile pages with that agency. Some do not.
Therefore, I need to have a way to test if that member has a profile on the agency's website, hosted elsewhere, and provide a link to their profile if they do and not if not. I know I can use fopen() and test on the return value of that, but I find with some of the larger cast lists its taking a while to generate the pages. Ideally I need a way to just test to see if the page exists on the other server and not actually download the whole thing each time.
I know that file_exists() works with URL wrappers in PHP5, but that's not much help in this situation (the server is running PHP4). I wondered if anyone else had any bright ideas on ways it could be done which might be a little quicker
Cheers,
Jonathon