running a php file without calling it
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
精彩评论