I'm green at running php in the command line, and need to find a way to execute a php script by loading a web page in my browser. I don't need any return values, but only need to make the script to run/execute. So, once "page.php" is loaded in the browser, a script which is inside page.php will begin running in terminal/cli.
I've tried doing this by adding the line <?php exec('php script.php') ?>, but it doesn't work. Is this possible?
UPDATE:
Provide some code to give insight/clarity on my setup to help with testing. Can the script be ran by putting it in the body like below, or does it need to be called explicitly somehow?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Web Page</title>
<link href="style.css" rel="stylesheet" type="text/css">
<?php include_once 'check_login_status.php'; ?>
</head>
<body>
<?php exec('php /Applications/XAMPP/htdocs/site_root/script_to_run.php'); ?>
<div id = "wrapper">
<div id = "nav"><?php include_once 'navigation.php'; ?></div>
<div id = "top"><?php include_once 'top.php'; ?></div>
<div id = "main"></div>
</div>
</body>
</html>
exec()call is the path to the script which is unknown to the php interpreter started on CLI, since it (typically) will not start with the working directory you apparently expect.php /path/script.phpit works fine. I'm just having trouble running it as described above. I haven't had time with using ajax, and just practicing new things with php basically.<?php exec(path/script.php); ?>. I changed it, but it's still not executing for some reason. I also should have mentioned that it's running on localhost in XAMPP.