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 1041891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:25:20+00:00 2026-05-16T15:25:20+00:00

This bug has given me hours of anguish. This is a simplified version of

  • 0

This bug has given me hours of anguish. This is a simplified version of what I’m doing:

[01] $h = get_headers($url, 1);
[02] $resp_code = $h[0];
[03] $resp_code = strtolower($resp_code);
[04] $resp_code = str_replace(' ','',$resp_code);
[05] echo 'just before going in. $resp_code = ' . $resp_code . '<br/>';
[06] switch ($resp_code) {
[07]   case 'http/1.1200ok':
[08]     echo '200';
[09]     break;
[10]   case 'http/1.0301movedpermanently':
[11]     echo '301';
[12]     break;
[13]   case 'http/1.0302movedtemporarily':
[14]     echo '302';
[15]     break;
[16]   case 'http/1.0404notfound':
[17]     echo '404';
[18] }
[19] echo 'just got out.';

The output I get. trying different urls, is different, for some urls it works correctly and for some it does not output any response code at all! Even though from the what echo shows on line 5 you expect one of the cases should be entered, it does not, and the next output comes from line 19.

You might wonder why I have converted the response codes to all lower, and stripped spaces, that was done as an attempt to factor out any minor differences there might be between text sent by different servers. I’m not aware if that could happen or not, it was done just in case and out of dismay 🙁

Could it be character encoding related? inflation/deflation? a bug in PHP? a virus on my system?

Any help would be greatly appreciated.

  • 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-05-16T15:25:20+00:00Added an answer on May 16, 2026 at 3:25 pm

    The last three headers are with http/1.0. So no case will be matched if it is a 1.1 server and it doesn’t return 200.

    Maybe you should try:

    $h = get_headers($url, 1);
    $h = explode(' ', $h[0]);
    $responseCode = $h[1];
    
    switch ($responseCode) {
        case '200':
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
Does anyone know if this subversion bug has been dealt with? https://svn.apache.org/repos/asf/subversion/tags/1.6.9/www/faq.html#windows-access-denied I'm getting
I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
I'm not sure if this is a bug or just some crazy new thing
I can't figure out if this is a bug in Firefox or an anomaly
This is a minor bug (one I'm willing to live with in the interest
This is a registered bug ( Bug ID: 6515708 ) but does anyone have
This is a fairly involved bug, and I've tried looking around to find other
Edit: This is a confirmed bug in jQuery 1.3.1. It is fixed in jQuery
Not sure if this is intended behavior or a bug or a wrong function

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.