I've read through many, many threads on this and still can't wrap my head around it.
Here's my basic issue:
header.php includes a file called navigation.php. Within navigation.php, $previous and $next are defined. Using echo statements I have verified they have values.
Next, header.php includes a file called backnext.php. I need backnext.php to know the values of $previous and $next. If I declare them as global at the top of backnext.php, I don't get errors, but echo statements show they are empty. If I don't, I get an undefined variable error.
Where exactly do I need to declare them as global to have backnext.php be able to read their values correctly?
None of these files are using functions or classes.
codeheader.php: … include '../../includes/navigation.php'; //1st echo previous echo $previous; … echo '<div id="backnext">'; // include '../../includes/leftnavbar/backnext.php'; echo '</div>'; //2nd echo previous echo $previous … navigation.php … $previous = $m["$p"]; … backnext.php … // 3rd echo previous echo "previous is $previous"; …code1st says index.php, 2nd says index.php, 3rd says previous is , no value.