Files and Directories
|
|
|
|
<?
/*
This generalized code snippet finds out the current file name without the extension part and can be of use in any template driven site where you have to dynamically generate names of graphics or other files to be loaded depending on the name of the page loading. All you have to do is use a uniform naming procedure for those files including the page name. Being generalised it doesnt matter how comlicated the URL is or how deep the current file is embedded. It still pulls out the name correctly.
This can be used as an include file or even as a function with minor changes.
Use variable $page in your program to build names of graphics or other files to be loaded for the current page.
*/
$page = getenv(SCRIPT_NAME); $page = split("/", $page); $n = count($page)-1; $page = $page[$n]; $page = split(".", $page, 2); $page = $page[0]";
?>
|
|
|
Usage Example
|
<IMG SRC="<? echo "$page-banner.gif"; ?>" WIDTH=599 HEIGHT=60 BORDER=0 ALT="">
|
|
|
Rate This Script
|
|
|
|