-1

Just a quick question (I Hope) I'm calling two PHP script using require_once, those script have some variables in PHP, JS, etc.

<?php require_once "page1.php";?>
<?php require_once "page2.php";?>

The issue is that page2.php have some variables with the same name in page1.php but with different values

Is there any way to require page1.php, show the content and after "release" or "clean" the content of variable in memory in order to require page2.php without conflics?

I know, will be more simple to change name of variables... But, I need ask ;)

Thanks for your help

  • You can use [name-space](http://php.net/manual/en/language.namespaces.basics.php) to avoid such conflicts – MaxZoom Aug 30 '16 at 21:38

1 Answers1

0

If you have same var in 2 script the 2nd will override the first one. If you want to prevent this you have to wrap your code into a function or a class.

Sylwit
  • 1,497
  • 1
  • 11
  • 20