I'm starting with OOP in PHP and I have an issue with global variables.
Example of my current structure:
test.php REQUIRES globals.php and also INCLUDES classes.php.
globals.php has this code:
global $something;
$something = "my text";
and classes.php looks like this:
global $something;
class myClass {
public $abc = "123";
public $something;
public function doSomething() {
echo $this->abc."<br>";
echo $this->something;
}
}
$class = new myClass();
$class_Function = $class->doSomething();
print_r($class_Function);
At the end, test.php only shows "123".
I tried using "include()" instead of "require" for globals.php but didn't work. Neither did including globals.php in classes.php.