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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:23:58+00:00 2026-06-16T00:23:58+00:00

For instance, using this code: $curl = curl_init(); curl_setopt_array( $curl, array( CURLOPT_RETURNTRANSFER => true,

  • 0

For instance, using this code:

 $curl = curl_init();
 curl_setopt_array( $curl, array(
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_URL => "$url" ) );
 curl_exec( $curl );
 $header = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
 curl_close( $curl );

$url = "http://upenn.edu" will not work, while $url = "http://www.upenn.edu" will work.

Without the www. the response code I get is 0, whereas with the www. it is 200.

If I were to use PHP get_headers("http://upenn.edu"), I would get two errors:

Warning: get_headers() [function.get-headers]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

and

Warning: get_headers(http://upenn.edu) [function.get-headers]: failed to open stream: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

However, when I use the exact same code, http://google.com will work (as well as the expected http://www.google.com.)

Then, for a website such as http://www.dogpile.com, the www. part included returns a response code of 0 whereas without the www., I get a 302.

Why is this? and is there a better method to use in order to ensure reliable results (i.e., where a www. is not present, yet the response code is still returned?)

I am new to using cURL and dealing with headers and response codes, so any help is appreciated. Thank you.

  • 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-16T00:23:59+00:00Added an answer on June 16, 2026 at 12:23 am

    Your question, even asked because of using curl now, is actually something totally independent to curl. Other client http libraries will be the same with these examples because it is related to the domain name system and services running on a computer.

    Curl is a HTTP library. If you do a HTTP request, by default you will try to connect to port 80 on a remote computer.

    The remote computer is identified by an IP address. That is a number like 173.194.35.134 – you probably know that already.

    Most often not the numbers are used but some domain names, for example google.com for 173.194.35.134.

    So telling curl to use the URI http://google.com/ will open a connection to

    173.194.35.134:80
    

    The domain name system will resolve the domain google.com to the IP address.

    Domain names can be organized in levels. Each level is separated by a dot .. The so called Top Level Domain (TLD) is the part most on the right, for google.com that is com. The Second Level Domain (SLD) is respectively google then. And with www.google.com you have another domain name, with three levels then. The www is commonly refered to as Subdomain.

    The most important part here is that for every different domain the DNS system can return a different IP address.

    Therefore www.google.com and google.com can be two totally different things. The www subdomain is only a common convention to name the webserver on a network organized with a SLD.TLD.

    So by this being common you could try both and see which one works. However I would not try more than with and w/o www.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to parse XML in the instance variable response : @implementation
I'm using this code to prevent a second instance of my program from running
I'm using Boilerpipe to extract text from url, using this code: URL url =
I wrote this code to create a redis client instance using System; using System.Collections.Generic;
I was deploying an Azure instance using Visual Studio (2010) and i get this:
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I'm trying to pass my dbhelper instance from one activity to another using this
For instance is it possible to write this if (variable != null) without using
I'm using the first answer to this question Overcoming Python's limitations regarding instance methods
I'm able to save the captured image from a barcode scanner using this code:

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.