Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7891785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:42:22+00:00 2026-06-03T06:42:22+00:00

I found this nifty way to check if a page really exists: $headers=@get_headers($imageurl); if(strpos($headers[0],’200′)===false){

  • 0

I found this nifty way to check if a page really exists:

$headers=@get_headers($imageurl);
if(strpos($headers[0],'200')===false){
    echo "not valid";
    exit;
}

What I need to achieve, though, is to check whether on that page is really only an image.
For example, when you try the following link:
http://www.google.com/image.jpg
it will return 200 because Google has it’s own error page – however, it should be possible to find out not only that there is no image on that page, but also that an image is not the only thing on that page, even when there is other content (like here: http://www.kapstadt-entdecken.de/wp-content/gallery/robben-island/1robben-island.jpg).

How I can I achieve that?

Thanks a lot!

Dennis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:42:23+00:00Added an answer on June 3, 2026 at 6:42 am

    You will probably want to use HEAD requests when getting headers (it doesn’t do that by default):

    stream_context_set_default(array(
        'http' => array(
            'method' => 'HEAD'
        )
    ));
    

    Second, you can pass a second parameter to get_headers to parse it for you:

    $headers = get_headers($imageurl, 1);
    

    Then, you can check the rest as per normal:

    if (strpos($headers[0], '200') === false) {
        echo "not valid";
        exit;
    }
    
    if (isset($headers['Content-Type']) && 0 === strncmp($headers['Content-Type'], 'image/', 6)) {
        echo "valid image";
    } else {
        echo "probably not an image";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Found this question that explained a way to communicate between layers. However there is
I built this nifty little weather/clock app as a way of learning to work
I found this nifty plugin that lets me create dashboard widgets from external files.
I found this nifty code snippet on several sites, allowing me to analyze the
Found this here http://sla.ckers.org/forum/read.php?2,15812,page=2 If you copy the title of the question and run
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even
Found this is some example CSS I was reading and I'm having a hard
i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.