I’m using a script to store some data in my sql database and then creating xml documents from that… I need the script to tell/pretend another script it is finished when the first part is over and then run the xml thing…
Maybe you’re looking to have a cron job make any new xml docs later on. That would just be a separate thing. Store the data and be done. Then a second script will run periodically - finding any data it hasn’t processed yet and making the xml.
You could send the request to create the XML using a JavaScript <script> element. The request for external javascript still gets called even when javascript is turned off in the browser. (In the browsers I tested it does)
Just calling an external javascript file will execute that file. So you could call a server-side php script from a client-side script element, and as long as it outputs javascript it will execute without creating an error. Even if Javascript is turned off it will still execute the file.
The phrase you are looking for is “asynchronous execution”. Parts of PHP support async operations, most of it doesn’t, and the parts that do won’t function exactly the same on every host.
It is in your user’s best interest to not throw arbitrary delays into code. PHP also has an execution time limit when running on a web host. When PHP runs from the command-line (e.g. via a cron job), there generally is no time limit. This seems like one of those things best left to a long-running cron script to process. Write a temporary file that indicates that the cron script needs to check the database. The cron script checks for that file’s existence every second (PHP has some nuisance issues here - see clearstatcache()) - if so, it runs the SQL query looking for what needs processing, does the processing, and then updates the database to indicate that it is done. Of course, you said there is an XML file that is generated, so you can just check to see if it exists at that point.
The OS is the provider of asynchronous execution in this case instead of trying to do it all from within PHP. Plus, you can simply return to the caller and then use Javascript/jQuery to show a “please wait…” box to the user that pings the server every couple of seconds to see if the process is complete instead of having a web browser hang forever and not fire onready/onload handlers.