title: Undefined variable error in PHP include file
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6058781/undefined-variable-problem-with-php-function">Undefined variable problem with PHP function</a>  </p>
  </blockquote>
  
  
  
  <p>Can someone tell me why I keep getting undefined variable error messages in my PHP include files?</p>
  
  <pre><code>&lt;?php
  
  $page = 1;
  
  if (isset($_REQUEST['page'])) {
    $page = $_REQUEST['page'];
  }
  
  function phpRocks() {
    require("includes/dostuff.php");
  }
  
  if ($search) {
    phpRocks();
  }
  
  ?&gt;
  </code></pre>
  
  <p>Then in dostuff.php:</p>
  
  <pre><code>&lt;?php echo $page; ?&gt;
  </code></pre>
  
  <p>This is the error I'm getting:</p>
  
  <blockquote>
    <p><br /><b>Notice</b>:  Undefined variable: page in <b>/dostuff.php</b>
    on line <b>61</b><br /></p>
  </blockquote>
  
  <p>Attn down voters/close requesters: Doesn't show any research effort? How so? What else should I have added? I have been stumped over this for a half hour and cannot find any other posts that answer this question. Do I need to be a PHP expert in order to post questions (therefore I wouldn't be posting any questions!)??</p>