I have a require for a file in my php code. This require exists twice in the code.
require 'test.php';
echo $result;
require 'test.php';
Is there a way to clear all the variables the first require sets before running the second require on the exact same file?
You could wrap the
requirein a function, if you don’t use global vars. In that case all the variables you create will be limited to the function scope.But it would be much better to create a class as it was suggested in the comments.