File exists function for anchor points?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anivad
Forum Commoner
Posts: 80
Joined: Thu Apr 09, 2009 11:16 pm

File exists function for anchor points?

Post by anivad »

Is there something similar to the file_exists function that can be used to apply to anchor points?

Such that the code can check if for example 'page.htm#anchor' exists, rather than just 'page.htm' on its own.

Thanks!
User avatar
genconv
Forum Commoner
Posts: 34
Joined: Sun Jul 05, 2009 9:27 am

Re: File exists function for anchor points?

Post by genconv »

Is there something similar to the file_exists function that can be used to apply to anchor points?
No, there isn't. (Of course you can create your own function or a class for that)

If your site is on-line, you can use for example the function file_get_contents to check if URL exists:

Code: Select all

 
if(file_get_contents('http://www.yoursite.com/page.htm#anchor'){
  echo 'URL exists';
} else {
  echo 'URL does not exists';
}
 
anivad
Forum Commoner
Posts: 80
Joined: Thu Apr 09, 2009 11:16 pm

Re: File exists function for anchor points?

Post by anivad »

That works; thanks!

Though there seems to be an anchor bug in Firefox.
Post Reply