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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:36:38+00:00 2026-05-25T03:36:38+00:00

I have a PHP file that invokes another PHP file via curl. I am

  • 0

I have a PHP file that invokes another PHP file via curl. I am trying to have the second file send a response back to the first to let it know that it started. The problem is the first can’t wait for the first to finish execution because that can take a minute or more, I need it to send a response immediately then go about it’s regular business. I tried using an echo at the top of the second file, but the first doesn’t get that as a response.
How do I send back a response without finishing execution?

file1.php

<?php
$url = 'file2.php';
$params = array('data'=>$data,'moredata'=>$moredata);

$options = array(
    CURLOPT_RETURNTRANSFER => true,     // return web page
    CURLOPT_HEADER         => false,    // don't return headers
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
    CURLOPT_ENCODING       => "",       // handle all encodings
    CURLOPT_USERAGENT      => "Mozilla", // who am i
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
    CURLOPT_TIMEOUT        => 120,      // timeout on response
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    CURLOPT_TIMEOUT        => 10,        // don't wait too long
    CURLOPT_POST           => true,     // Use Method POST (not GET)
    CURLOPT_POSTFIELDS     => http_build_query($params)
);
$ch = curl_init($url);

curl_setopt_array( $ch, $options );
$response = curl_exec($ch); // See that the page started.
curl_close($ch);
echo  'Response: ' . $response;
?>

file2.php

<?php
/* This is the top of the file. */
echo 'I started.';
.
.
.
// Other CODE
.
.
.
?>

When I run file1.php it results in: ‘Response: ‘ but I expect it to be ‘Response: I started.’ I know that file2.php gets started because ‘Other CODE’ get executed, but The echo doesn’t get sent back to file1.php, why?

  • 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-25T03:36:39+00:00Added an answer on May 25, 2026 at 3:36 am

    The answer ended up being that CURL does not behave like a browser:

    PHP Curl output buffer not receiving response

    I ended up running my 2nd file first and my 1st file second. The 2nd file waited for a ‘finished’ file write that the 1st file did once it, obviously, finished.

    At this point, it seems like the database would be a better place to store messages for files to be able to pass between each other, but a file would also work for a quick and dirty job.

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

Sidebar

Related Questions

I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have a php file that I am trying to send the output in
First I have a PHP file that gets data and file from a HTML
I have a php file that includes another one using include() I defined a
I have a PHP file that contains a lot of if and else statements
I have a php file that contains a form (which contains 2 input boxes
I have a PHP file that I need it to detect it's directory it's
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
I have some setup code in my functions.php file that sets permalinks and adds
I have some issues with a PHP file that is not working properly. The

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.