How would I make my server run a php script by triggering it manually using php? Basically I have a pretty big cronjob file that is ran every 2 hours, but I want to be able
I think this is what you are looking for
<?php include ('Scripts/Php/connection.php');
//The connection.php script is executed inside the current file ?>
The script file can also be in a .txt format, it should still work, it does for me
e.g.
<?php include ('Scripts/Php/connection.txt');
//The connection.txt script is executed inside the current file ?>
The OP refined his question to how a php script is called from a script. The php statement 'require' is good for dependancy as the script will stop if required script is not found.
#!/usr/bin/php
<?
require '/relative/path/to/someotherscript.php';
/* The above script runs as though executed from within this one. */
printf ("Hello world!\n");
?>
<?php
$output = file_get_contents('http://host/path/another.php?param=value ');
echo $output;
?>
Possible and easiest one-line solution is to use:
file_get_contents("YOUR_REQUESTED_FILE");
Or equivavelt for example CURL.
I prefer to use
require_once('phpfile.php');
lots of options out there for you. and a good way to keep things clean.