I have two files, lib.php and index.php now what I want to do is lib.php to detect how it is called. example:
include("http://site.com/lib.php"); and include("./lib.php"); ?>
how can i teach lib.php so when it is called via URL (first example) it echos "URL" and when it is called by PATH it echo "PATH" .
When the file is in the url then its in the $_GET array
just do a search for the file in the $_GET array = if its there then its URL otherwise its include
Of course it could be in both 😃
GM
Originally posted by trooper When the file is in the url then its in the $_GET array just do a search for the file in the $_GET array = if its there then its URL otherwise its include Of course it could be in both 😃
Originally posted by trooper When the file is in the url then its in the $_GET array
just do a search for the file in the $_GET array = if its there then its URL otherwise its include Of course it could be in both 😃
This is not very efficient and reliable 🙁
someone know other better way to do it ?
PS. the lib.php and index.php may be in different folders and in some case they may have same names 😐
You didn't ask for a reliable foolproof way just a way of doing it .........
Ask the right questions and you'll get expected answers
LOL
In scripts doing the inclusion... define('INCLUDING_LIBphp_LOCALLY',true); include(...lib.php, somehow);
In lib.php if(defined(INCLUDING_LIBphp_LOCALLY)) { it's local } else { it's not }
Some variant on that?
Why do you need something like this?