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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:07:27+00:00 2026-05-23T13:07:27+00:00

I am using cURL in PHP to write a function to get a remote

  • 0

I am using cURL in PHP to write a function to get a remote xml file into my local folder. Everything works fine however I have a question:

  $fileIn = curl_init("http://some-remote-host.com/file.xml);
  $fileOut = fopen('myLocal.xml", "w");

  curl_setopt($fileIn, CURLOPT_FILE, $fileOut);
  curl_setopt($fileIn, CURLOPT_HEADER, 0);

  $isCopied = curl_exec($fileIn);
  curl_close($fileIn);
  fclose($fileOut);

  if(!$isCopied)
     return false;
  else
     //do something else

Based on the documentation I read, $isCopied is supposed to be false when the remote file does not exist, and there shouldn’t be myLocal.xml but my if(!$isCopied) doesn’t seem tobe working. And this is the content of my myLocal.xml

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL something.xml was not found on this server.</p>
<hr>
<address>Apache Server at somehost.com Port 443</address>
</body></html>

My question is: How to get a boolean variable telling me when it succeeded and when it did not. (means when the remote file doesn not exist).

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-05-23T13:07:28+00:00Added an answer on May 23, 2026 at 1:07 pm

    You can use

    curl_getinfo($fileIn, CURLINFO_HTTP_CODE); 
    

    to see what http code was returned (you’re looking for 200).

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

Sidebar

Related Questions

I want to POST an URL using CURL and php. There is a big
I am attempting to POST against a vendor's server using PHP 5.2 with cURL.
I'm familiar with CURL in PHP but am using it for the first time
I'm making a call to download an XML file and write it to a
I'm using PHP Curl to measure download times for a webpage. I know this
I am trying to post to a REST service using PHP cURL but I'm
I'm trying to download users profile picture from facebook in PHP using this function
I am using PHP CURL to fetch data from a server. The response can
im retreiving a webpage as a string using curl and php code: $ch =
How do you pass $_POST values to a page using cURL ?

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.