This article mainly introduces the automatic running method of PHP files, analyzes the two automatic refresh methods and their advantages and disadvantages, for more information about how to automatically run PHP files, see the next article. I have analyzed the two methods and their advantages and disadvantages. For more information, see
This document analyzes the automatic running method of PHP files. We will share this with you for your reference. The details are as follows:
Two methods are analyzed here:
Method 1:
A. php file content is as follows:
However, there is a disadvantage here. you need to first run this php file, such as running through url :#
You only need to execute the command once and then close the page.
In addition, when Apache/IIS is restarted, this script will not be executed.
To this end, I thought of another method:
Run the following command in cmd:
php-win.exe -c "c:\php\php.ini" -f C:\Apache2.2\htdocs\a.php
(This operation only needs to be run once, which will shorten the running time .)
In this case, even if you restart Apache/IIS, the script will still run.
Disadvantages: restart the machine or kill php-win.exe. of course, it cannot run ......
In this solution, you can add the startup item and set it to bat. This should be a perfect solution!
Method 2:
B. php content:
Then write a bat file and write it in it:
c:\php\php -c c:\php\php.ini -f c:\Apache2.2\htdocs\b.php
Save
Then use the at command to add it to the scheduled task.