I want to know all the variables that have been declared within an include file.
Example code is:
Include file:
<?php $a = 1; $b = 2; $c = 3; $myArr = array(5,6,7); ?>Main file:
<?php $first = get_defined_vars(); include_once("include_vars.php"); $second = get_defined_vars(); $diff = array_diff($second ,$first); var_dump($diff); $x = 12; $y = 13; ?>
My attempt to use difference of get_defined_vars() does not seem to give accurate information. It gives:
array(2) {
["b"]=>
int(2)
["c"]=>
int(3)
}
$a and $myArr seem to be missing. What are other methods I can use?