I reread your posts and I think we are still unsure what you are actually trying to do.
As far as I see it, you have PHP code that “includes” a file into the current file in some code.
Of course, you did not show us how that code works. I will assume you have a variable that
contains the file needed to be loaded by an include command. So, you want to load that file
conditionally? Correct? Well, you can do this with session variables with ease. Or, you could
do the complicated version you mentioned by scanning the current file. Either is possible.
First, let’s explain how PHP works. First, you request a PHP page on the server. The page is executed
SERVER-SIDE and the PHP code is executed. The results of the HTML page along with anything outputted
from the PHP code is then sent to the browser. The browser then “renders” the display using HTML, CSS,
Javascript (CLIENT-SIDE) and other in-browser programming tools. So, when all of this happens, the
PHP code is SERVER-SIDE only. Therefore, there really isn’t a “current page” running at any one monent
in time. The “LIVE” current page depends on where you are talking about. If you are talking about the
current page in the PHP code, it is the actual page SERVER-SIDE before it is displayed on the screen.
If you are talking about that “LIVE” page, you can load the page into a variable with very little code.
Then, you can just use a string search to locate if those tags such as “
” are inside
the string. Then, your if then code would sort it out for you. But, the problem with this is where do these
tags come from to start with? If you are programming a variable display where these tags are loaded,
why are you not just doing your new code in that code instead of trying to do it in a new page?
Did that make sense? If you are attempting to “ADD” content to a page already designed and posted to
the screen, you would have to do that CLIENT-SIDE which would mean using Javascript to load the new
content. If you want to do it SERVER-SIDE in PHP, just do it in the same code that creates the tags in
the first place. Hope that makes sense… Good luck!