I think I understand. You want your own template system? Instaid of using a 3rd party system or, use inline PHP, or use a common PHP page which serves all pages, or, using .htaccess to redirect old pages to a PHP page which supports templating.
Sounds like some recursive coding, which means you need to return a string from your function.
You need to search for "<--INCLUDE" using stripos If found, you then search for "-->" after the start point using the offset parameter.
Once you have the start and end positions, you need to extract the file name using some more string processing.
If there is a valid filename, you then call the function again to get the templated string for the given filename. You then need todo what I call a StuffString command. Delphi had one build in that was great.
http://delphi.wikia.com/wiki/StuffString_Routine
So, you stuff the new string into the start and end position of the <!-- INCLUDE tag. And, then continue processing until no more INCLUDES are found.
With this kinda stuff, its easy to have an enless loop, so, you might have to keep a recursion depth counter. Also, some of the string process can be a little tricky to debug, but, then thats the fun of it.
BTW: There are other ways todo template systems.