I am trying to include a file based on the current page of a URL the user is on.
The files are stored in /includes/ in all cases and on the same domain.
If the current URL the user is on is for example:
www.website.com/page/text_i_want.php?info=tree
<?php $url = curPageURL();?><?php include ("{$_SERVER['DOCUMENT_ROOT']}/includes.'/'.$id = substr( $url, strrpos( $url, '/' )+1" ?>
This is what I have but even if that did work, it would't remove a everything after and including the .php and add .txt to the end
I just want to grab text_i_want from the end of the URL (not including the dynamic part) and add .txt to the end so effectively I am including:
{$_SERVER['DOCUMENT_ROOT']}/includes/text_i_want.txt
I keep getting an ';' error and syntax error, unexpected T_ECHO with what I have.
Update:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/' . basename($_SERVER['REQUEST_URI'], '?'.$_SERVER['QUERY_STRING']); ?>
That code grabs the file name at the end of the URL, which is what I want. I am just unsure how to replace .php with .txt