title: My First Function returns undefined variable ($pageName) error on line #14
body: <p>Newb here.</p>
  
  <p>I'm trying to create my first php function which will get the name of the file, stripe out the <code>'.php'</code> extension and return a string which is the name of the page file without the <code>'.php'</code> file. This if i was using the index page, the title tag would read 'Index'. </p>
  
  <p>To create the function, first i wrote the following process which did what I hoped:</p>
  
  <pre><code>$fileName2 = basename($_SERVER['PHP_SELF']);
  $pageName2 = str_replace(".php","", $fileName2);
  </code></pre>
  
  <p>However when i try to put it into the context/format of a function i get an error stating:</p>
  
  <blockquote>
    <p>NOTICE: UNDEFINED VARIABLE: ITC240.PHP ON LINE 14</p>
  </blockquote>
  
  <p>Here is what i believe to be the relevant code:</p>
  
  <p><strong>inc_function.php:</strong></p>
  
  <pre><code>function GetPageName($pageName) {
  $fileName = basename($_SERVER['PHP_SELF']);
  $pageName = str_replace('.php','', $fileName);
  }
  </code></pre>
  
  <p>I call the function between the title tags: </p>
  
  <pre><code>&lt;?php echo GetPageName(); ?&gt;
  </code></pre>
  
  <p>(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).</p>
  
  <p>Any help or instruction is very much appreciated</p>