call another php file in php code example
Example 1: php import function from another file
File1.php :
<?php
function first($int, $string){
return $string;
}
?>
File2.php :
<?php
include 'File1.php';
echo first(1,"omg lol");
?>
Example 2: run php script from another php
<?php
include('log test.php');
$output = shell_exec('php filename.php');
echo "<pre>$output</pre>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/Ia2/Watering/tests/log%20test.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
echo "<pre>$output</pre>";
?>