开发者

running a php file without calling it

开发者 https://www.devze.com 2023-03-09 18:37 出处:网络
Ho开发者_如何学Gow can I run a php file without opening in browsers? Can I do that with php? or Should I use other languages?

Ho开发者_如何学Gow can I run a php file without opening in browsers? Can I do that with php? or Should I use other languages?

i.e. sending a birthday mail to users otomaticly

i.e.2 send a ping every 5 hours etc


for automate your scripts you should use cron


I'd use python for it.

However, PHP works perfectly fine for this purpose. It has the cli SAPI which is meant for commandline scripts (including cronjobs etc.).

Simply start your PHP file with the hashbang line pointing to the PHP interpreter:

#!/usr/bin/php
<?php
echo 'hello shell';


CLI is command line interface. And from cron you can start your PHP scripts through command line.

Try this to start and you will understand what to do next: http://www.php.net/manual/en/features.commandline.usage.php

Form you command line run something like C:>c:\php\php.exe c:\path\to\your\script.php

0

精彩评论

暂无评论...
验证码 换一张
取 消