
October 27th, 2012, 09:55 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Hi,
this doesn't make sense. First of all, $val is a local variable. It isn't visible anywhere except for this specific function while it's running. I guess what you actually want is an attribute. Secondly, even if this was an attribute, you'd need to call foo() to even set the attribute to "bar". Before you'll just get null.
I think you should look into the OOP basics again. A working example would be
PHP Code:
<?php
class A {
public $var = 'bar';
}
class B extends A {
public function bar() {
echo $this->var;
}
}
$a = new B();
$a->bar();
|