Hi all,
Got a problem with some PHP that I can't figure out. I'm sure it's staring me in the face but I'm not seeing it.
I won't post all the code but the jist is this:
For some reason, I can access and return the value of $variable through $Obj but when I use $this->Variable within a method of the class, its not returning a value.
I've checked for typos can't see anything wrong. No synxtax highlighting errors anywhere.
I can't see why it wouldn't work. All the methods are public and so is the variable.
Got a problem with some PHP that I can't figure out. I'm sure it's staring me in the face but I'm not seeing it.
I won't post all the code but the jist is this:
PHP:
Class MyClass {
public $Variable;
public function A() {
if(some conditions) {
// code here etc
// end result
$this->Variable = $min($somearray);
}
// more code here unrelated to $this->Variable;
}
public function B() {
// loads of code here, none of it touching $this->Variable
echo $this->Variable;
}
public function C() {
$this->A();
$this->B();
}
}
// Go to use the Class
$Obj = new MyClass();
$Obj->C(); // $this->Variable not echo'd
// but if I do this !!
echo $Obj->Variable; // I get the value I want !
For some reason, I can access and return the value of $variable through $Obj but when I use $this->Variable within a method of the class, its not returning a value.
I've checked for typos can't see anything wrong. No synxtax highlighting errors anywhere.
I can't see why it wouldn't work. All the methods are public and so is the variable.
