0

How 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

3
  • 4
    Set the cron job to execute that file with the desired schedule Commented May 30, 2011 at 12:53
  • @Teneff: that link doesn't even exist (and if it did, it'd be likely to be unrelated to the php core). please don't post random links without testing them. Commented May 30, 2011 at 12:54
  • > dig www.php-cli.com A # ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 48196 - and some further investigation shows that the domain used for the nameserver entries of php-cli.com is not registered... Commented May 30, 2011 at 12:59

3 Answers 3

4

for automate your scripts you should use cron

Sign up to request clarification or add additional context in comments.

Comments

2

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';

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.