SOLVED: The error had nothing to do with require or include. It was completely unrelated to the question. Sorry about that. 🙁
I thought I had an understanding of require/include until now. I have a file named file_one that has something like this, $user_data = return_user_data_as_array(). My second file file_two, calls $user_data. Now, when I do a include 'file_two.php' into the file_one page after the functions and variables have been called, the page returns with undefined variable user_data. 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?
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.
File One
//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';
File Two or file_two.php
echo $profile_data['full_name'];
The answer had nothing to do with the problem in the question. The code in the question is correct.