I have a script scripty.php
Sometimes this script gets called through the browser.
Other times it gets called by another script on the server.
How can I (securely) check within scripty.php to see whether or not it is being called by the server?
in the form of an http URL
The $_SERVER["REMOTE_ADDR"]
variable that gives you the IP address of the client who made the request should be 127.0.0.1
when the script is called from the server.
you can create a variable before including your script
$by_script = true;
include("new_script.php");
and check it inside
Just a guess: You want to know, if the script its called trough a browser, or from CLI
var_dump(PHP_SAPI);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With