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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:21:55+00:00 2026-06-02T00:21:55+00:00

My php script uses php simplehtmldom to parse html and get all the links

  • 0

My php script uses php simplehtmldom to parse html and get all the links and images that I want and this can run for a duration depending on the amount of images to download.

I thought it would be good idea to allow cancelling in this case. Currently I call my php using Jquery-Ajax, the closest thing I could find is php register_shutdown_function but not sure if it can work for my case. Any ideas?

So once php is launched, it cant be disturbed? like fire ajax again to call an exit to the same php file?

  • 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-02T00:21:56+00:00Added an answer on June 2, 2026 at 12:21 am

    This is good only in case you are processing really massive data loads through AJAX. For other cases, just handle it in JS to not display result if canceled.

    But as I said If you are processing huge loads of data, then you can add a interrupt condition in every nth step of running script and fulfill that condition using another script. For example you can use a file to store a interrupt data, or MySQL MEMORY table.

    Example.

    1, process.php (ajax script processing loads of data)

    // clean up previous potential interrupt flag
    $fileHandler = fopen('interrupt_condition.txt', 'w+');
    fwrite($fileHandler, '0');
    fclose($fileHandler);
    
    function interrupt_check() {
       $interruptfile = file('interrupt_condition.txt');
       if (trim($interruptfile[0]) == "1") {    // read first line, trim it and parse value - if value == 1 interrupt script
          echo json_encode("interrupted" => 1);
          die();
       }
    }
    
    $i = 0;
    foreach ($huge_load_of_data as $object) {
       $i++;
       if ($i % 10 == 0) { // check for interrupt condition every 10th record
          interrupt_check();
       }
    
       // your processing code
    }
    interrupt_check(); // check for last time (if something changed while processing the last 10 entries)
    

    2, interrupt_process.php (ajax script to propagate cancel event to file)

    $fileHandler = fopen('interrupt_condition.txt', 'w+');
    fwrite($fileHandler, '1');
    fclose($fileHandler);
    

    This will definitely affect performance of your script, but makes you a backdoor to close execution. This is very simple example – you need to make it more complex to make it work for more users simultaneously, etc.

    You can also use MySQL MEMORY Table, MEMCACHE – Non-persistent Caching Server or whatever non-persistent storage you could find.

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

Sidebar

Related Questions

I have a PHP script that does the following: Uses file_get_contents() to get content
I am running a PHP script that uses the passthru function to run system
I have a php script that uses curl to get the contents of a
I have a php script that is triggered from my app. This script uses
I have a PHP script that uses CURL to fetch a remote page and
I have a php script that uses some css/javascript tabs, they work on my
I am trying to write a PHP script that uses the pdftk app to
I have a PHP script that is kicked off via ajax. This PHP script
I'm writing a PHP script which uses serialized arrays to store data. How can
I have developed a PHP script that uses $_REQUEST[] superglobal. A typical client request

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.