Analysis of the automatic operation method of PHP files,
This paper analyzes the automatic operation method of PHP files. Share to everyone for your reference, as follows:
Here are two methods of analysis:
The first method:
The contents of the a.php file are as follows:
<?php ini_set ("Error_log", "C:\php\php_error.log"); Error_log ("a.php is execute----------", 0); Ignore_user_abort (); Background non-blocking operation Set_time_limit (0);//Always run to me $zhoz _execute_time = 30;//Run time seconds, set here to run once a minute. Do { //What you want to do here can be written error_log ("A is DO!!!! ----------", 0); Sleep ($zhoz _execute_time); Run by the specified track Time } while (true);?>
But here is a drawback, you need to run this PHP file, such as running through the URL: http://www.zhoz.com/zhoz.php
This is done just once, then close the page.
Also, this script will not execute when the Apache/iis is restarted.
To do this, I thought of another method:
Run under cmd:
Php-win.exe-c "C:\php\php.ini"-F C:\Apache2.2\htdocs\a.php
(It also runs once, and running more time will shorten the operation.) )
That way, even if you restart Apache/iis, the script will still run.
There are drawbacks: Restart the machine or kill the process Php-win.exe, of course, it can not run ...
This solution can be added to the startup item as bat should be perfectly solved!
The second method:
b.php content:
<?php $fp =fopen ("C:\\test\\a.txt", "A +"); Fwrite ($fp, "test \ r \ n"); Fclose ($FP);? >
Then write a bat file in which to write:
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
More about PHP related content readers can view this site topic: "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", " PHP Math Skills Summary, "PHP Regular Expression Usage summary", "PHP Operations and Operator Usage Summary", "PHP string Usage Summary" and "PHP common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1127915.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127915.html techarticle The automatic running method of PHP file is analyzed, and the automatic running method of PHP file is analyzed in this paper. Share to everyone for your reference, as follows: Here the analysis of two methods: first ...