Php include then grab end of current URL and combine them -
i trying include file based on current page of url user on.
the files stored in /includes/ in cases , on same domain.
if current url user on 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 have if did work, would't remove after , including .php , add .txt end
i want grab text_i_want end of url (not including dynamic part) , add .txt end including:
{$_server['document_root']}/includes/text_i_want.txt
i keep getting ';' error , syntax error, unexpected t_echo have.
update:
<?php include $_server['document_root'] . '/includes/' . basename($_server['request_uri'], '?'.$_server['query_string']); ?>
that code grabs file name @ end of url, want. unsure how replace .php .txt
i think need:
<?php include $_server['document_root'] . '/includes/' . basename(__file__, '.php') . '.txt'; ?>
update
according update, try $_server['request_uri']
php docs says: "the uri given in order access page; instance, '/index.html'".
if not want, give read on php server variables
Comments
Post a Comment