Inside a class, I have a method that reads a few variables from an external file. I then set member variables using these included variables. As soon as this method completes however, the member variables get reset to null. What am I doing wrong?
main.php
$bob = new Object();
$bob->init();
echo $bob->value;
Object.php
public function init() {
include('/includefile.inc');
$this->value = $included_value;
echo $this->value;
}
includefile.inc
<? $included_value = 'Hello World'; ?>
The echo inside Object.php will work correctly, but the echo outside in main will be null. value is a public variable inside the Object.php class definition.