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

  • Home
  • SEARCH
  • 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 8765611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:19:36+00:00 2026-06-13T16:19:36+00:00

The following code breaks once every 36 hours at a random time. The correctness

  • 0

The following code breaks once every 36 hours at a random time. The correctness of info.txt is assured. A simple print 'test'; or sleep(1); between the lines of $handle and while works around the problem, but why?

$handle = fopen("http://www.domain.do/info.txt", "r");
while (!feof($handle)) {
  // [do stuff]
}
fclose ($handle);

The code is run by a cron job.

  • 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-13T16:19:37+00:00Added an answer on June 13, 2026 at 4:19 pm

    Adding the sleep() or some delay will give the fopen time to retrieve the file from the location… I am presuming the ‘random’ effect may be traffic on the network causing retrieval to be slightly longer than usual.

    You could try to use cURL to retrieve data:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://www.domain.do/info.txt');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    

    $output will contain the contents of the file, so you would need to split the string into an array possibly using newline as delimiter… only guessing don’t know the content of the file 🙂

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

Sidebar

Related Questions

The following code breaks the Law of Demeter : public class Student extends Person
The following bit of code breaks in the upgrade to jquery 1.4: $().mousemove( function
I have the following line of code which works fine locally, but breaks when
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is
Why in the following code I see the whole page at once ? Thanks
The following code executes two threads (multithread), each with different time delays so that
I have the following code snippet to test a plain-text username/password against the AD,
The following code implements a simple singleton that ensures only 1 instance of my
The following line of code causes my program to break in a very strange
Following code produces a nested array as a result for keys containing three items:

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.