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

The Archive Base Latest Questions

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

For some reason the code below when I iterate through some urls, curl_exec never

  • 0

For some reason the code below when I iterate through some urls, curl_exec never returns anything. I’ve verified the urls it is getting are correct. I’ve manually checked them to see if there is output. I’ve tried removing CURLOPT_RETURNTRANSFER, and curl_exec would return true. I’m not sure why curl_exec isn’t returning the data that I need.

function _curl_get($urls)
{
    $html_str = '';
    foreach ($urls as $url)
    {
        $curl_handle=curl_init();
        curl_setopt($curl_handle, CURLOPT_URL, $url);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
        $html_str .= curl_exec($curl_handle);
        curl_close($curl_handle);
    }

    return $html_str;
}
  • 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-27T09:07:53+00:00Added an answer on May 27, 2026 at 9:07 am

    Check for errors:

    $data = curl_exec($curl_handle);
    if ($data === FALSE) {
       die(curl_error($curl_handle));
    } else {
       $html_str .= $data;
    }
    

    Never assume that an operation that depends on an external resource succeeded. There’s only ONE way things can go right, and literally hundreds/thousands of ways for things to go wrong. Assuming that the 1:100 or 1:1000 chance occured is a bad way to go.

    On a slight efficiency note, there’s no need to repeatedly instantiate/close a curl object. You CAN reuse it for multiple urls. Especially since they’re all being fetched the same way. Create one curl handle outside of the loop, re-use it repeatedly inside the loop (set the url each time), then close it after the loop finishes.

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

Sidebar

Related Questions

for some reason the below code is outputting the correct ticker in the location
See code below, for some reason it only works when I put a breakpoint
For some reason, the following code never calls Event::Event(Event&& e) Event a; Event b;
For some reason the code below isn't centering my Unordered List (I have the
For some reason the code below is not adding annotations to the map view.
For some reason the code below is returning the results, put not in the
Hello I have the code below that for some reason is not working: I
For some reason this PHP code below will not work, I can not figure
For some reason, the code below fails on the second line with run-time error
I've got the code below, but for some reason the Flash slider doesn't allow

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.