I am pretty sure this is not possible, but I can't find anything about it.
I have a *lot* of cron jobs that I need to schedule to run v. often (every min) and instead of adding all of them to the cron job list, I thought instead that I could add one php script that would then call all the various scripts and log errors etc.
So is it possible to call a php script from another php file? What are the options?
Cheers
Ed
How do you run one php script from another
Moderator: General Moderators
- The_Anomaly
- Forum Contributor
- Posts: 196
- Joined: Fri Aug 08, 2008 4:56 pm
- Location: Tirana, Albania
Re: How do you run one php script from another
I'm assuming that you mean something other than the require(), require_once(), include() and include_once() functions?
Re: How do you run one php script from another
Well what I want to do is run a number of php query strings from the 'mother' php file. e.g:
abracadabra.php?query1=start&query2=middle
etc. I dont think the include statements provide for that?
abracadabra.php?query1=start&query2=middle
etc. I dont think the include statements provide for that?
- The_Anomaly
- Forum Contributor
- Posts: 196
- Joined: Fri Aug 08, 2008 4:56 pm
- Location: Tirana, Albania
Re: How do you run one php script from another
From my understanding of what you want to do, put your GET data into an array, and loop through the array, require_once()ing the php file with the value of the querystring. It would then "process" any of the scripts with the same name as your query strings.
For example, you have two PHP files, Peanuts and Butter. You want to "process" them from the page Food.
food.php?cmd1=Peanuts&cmd2=butter
Something like that might work. Of course, if this was public, you'd want to do all sorts of filtering, as they can execute any PHP file with just a query string.
For example, you have two PHP files, Peanuts and Butter. You want to "process" them from the page Food.
food.php?cmd1=Peanuts&cmd2=butter
Code: Select all
$array = $_GET;
foreach( $array as &$value ) {
require_once("$value.php");
}