php - How to know if a script was included inside another script -
i new php , using incorrect approach because not used think php programmer.
i have files include other files dependencies, these files need have global code executed if $_post
contains values, this
if (isset($_post["somevalue"])) { /* code goes here */ }
all files contain code section, each 1 it's own code of course.
the problem since files can included in 1 of these files, code section describe executed in every included file, when post trhough ajax , explicitly use url of script want post to.
i tried using $_server
array try , guess script used post request, , though worked because right script, same script every included file.
question is:
- is there way know if file included file can test , skip code execute if
$_post
contains required values?
note: files generated using python script uses c library scans database it's tables , constraints, c library mine python script, work , if there fix single file, needs performed python script.
i tell reader (potential answerer) because think makes clear don't need solution works on existant files, because can re-generated.
from sounds of make improvements on code structure avoid problem. however, information given simple flag variable should trick:
if (!isset($postcodeexecuted) && isset($_post["somevalue"])) { /* code goes here */ $postcodeexecuted = true; }
this variable set in global namespace , therefore available everywhere.
Comments
Post a Comment