I have a php script, and i’d like it so that it will only show this certain text if you’re viewing the page in your browser, and it’s not included by another script..
For example
//foo.php
<?php
if(!included){
echo "You can only see this if this is the page you're viewing";
}
?>
//bar.php
<?php
include 'foo.php';
?>
Now, When you view “bar.php”, you should not see the text.. But if you open foo.php instead, you will.. How would i do this..? If at all possible..
Not possible per se, but if you are exposing the php page on a website, e.g.
example.com/bar.php, you can check$_SERVER['SCRIPT_FILENAME']if you are using apache.