title: Require/Include and Undefined Variables in PHP
body: <p>SOLVED: The error had nothing to do with require or include. It was completely unrelated to the question. Sorry about that. :(</p>
  
  <p>I thought I had an understanding of require/include until now. I have a file named <code>file_one</code> that has something like this, <code>$user_data = return_user_data_as_array()</code>. My second file <code>file_two</code>, calls <code>$user_data</code>. Now, when I do a <code>include 'file_two.php'</code> into the <code>file_one</code> page after the functions and variables have been called, the page returns with <code>undefined variable user_data</code>. I thought that if you include/require a file into your php code it would pick up any variables written in the original file? How would I fix this?</p>
  
  <p>Edit: I also want to mention that although the undefined variable error is popping up on my screen, the "undefined" variables are correctly echoed out.</p>
  
  <p>File One</p>
  
  <pre><code>//this require_once holds the function user_data()
  
  require_once 'core/init.php';
  
  $user_id = 1;
  
  $profile_data = user_data($mysqli, $user_id); 
  
  //this calls file two
  require_once 'file_two.php';
  </code></pre>
  
  <p>File Two or file_two.php</p>
  
  <pre><code>echo $profile_data['full_name'];
  </code></pre>