Let's say i have script1.php with the following contents:
And I want to access those variables from inside script2.php. Which is the preferred method?
Or is there simply no difference between the two, other than the way they are typed out?
Is there any difference if Method1 and Method2 are put inside a function instead of outside like it is now?
Thanks.
<?php
$GLOBALS['my_var'] = "hello world";
$GLOBALS['your_var'] = "goodbye";
?>
And I want to access those variables from inside script2.php. Which is the preferred method?
<?php
require_once ('script1.php');
# Which is a better/preferred method?
# Method 1:
global $my_var;
print $my_var
# Method 2:
print $GLOBALS['your_var'];
?>
Or is there simply no difference between the two, other than the way they are typed out?
Is there any difference if Method1 and Method2 are put inside a function instead of outside like it is now?
Thanks.