Automatically run PHP files

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.