Newb here.
I'm trying to create my first php function which will get the name of the file, stripe out the '.php' extension and return a string which is the name of the page file without the '.php' file. This if i was using the index page, the title tag would read 'Index'.
To create the function, first i wrote the following process which did what I hoped:
$fileName2 = basename($_SERVER['PHP_SELF']);
$pageName2 = str_replace(".php","", $fileName2);
However when i try to put it into the context/format of a function i get an error stating:
NOTICE: UNDEFINED VARIABLE: ITC240.PHP ON LINE 14
Here is what i believe to be the relevant code:
inc_function.php:
function GetPageName($pageName) {
$fileName = basename($_SERVER['PHP_SELF']);
$pageName = str_replace('.php','', $fileName);
}
I call the function between the title tags:
<?php echo GetPageName(); ?>
(I tried to put this in code block but every time i put anything in the title tags it didn't print for reasons i don't understand).
Any help or instruction is very much appreciated