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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:16:04+00:00 2026-06-06T03:16:04+00:00

I want to repeatedly check a variable every time php wakes up from sleep().

  • 0

I want to repeatedly check a variable every time php wakes up from sleep(). Further, if 3 minutes have passed without finding a particular variable then the function should stop checking. How would I go about this? This is the code I have thus far:

<?php
  $file = file_get_contents("file.txt");
  if($file == 0){
    sleep(3);// then go back to $file
  } else {
    //stuff i want
  }
?>
  • 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-06T03:16:05+00:00Added an answer on June 6, 2026 at 3:16 am

    If you want to keep doing something until something else happens, you want a loop. You have two things to check to see if you should exit the loop: the file variable and the length of time. You need to add a variable to keep track of the time, or you need to check the time each time you loop and compare it to the start time.

    <?php
    
         $file = file_get_contents("file.txt");
         $timesChecked = 0;
         while($file == 0 and $timesChecked < 60)
         {
             sleep(3);
             $timesChecked++;
             $file = file_get_contents("file.txt");
         } 
         if($file != 0)
         {
              // stuff i want
         } else {
              // 3 minutes elapsed
         }
     ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays and I want to check if every element in arr2
I have a python program/file that I want to run repeatedly and calculate the
I have a Bash script that repeatedly copies files every 5 seconds. But this
I have an alpha-numeric string and I want to check for pattern repetition in
I want to repeatedly zero a large 2d array in C. This is what
In my android app, I'm setting an alarm that I want to occur repeatedly,
For a linearLayout, I want to have a gradient along with a tiled (repeated)
Want to make a confirm box appear before someone leave my site. They have
I have a set of functions I want to be available to my web
Say you want to check if someone won a game of tic tac toe.

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.