KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a parent class and a subclass, the parent class has a constructer that sets a var and I would like to use that var in the subclass, I have it working but am getting confused by the keyword parent ? Example class Sub extends Parent { public function foo() { echo $this -> myVar; } } class Parent { var $myVar; public function __construct() { $this -> myVar = 'a'; } } This worked and I get the value of myVar , but am I supposed to be using the keyword parent and when I do I get an error, example, class Sub extends Parent { public function foo() { echo parent -> myVar; } } class Parent { var $myVar; public function __construct() { $this -> myVar = 'a'; } }
Tags (comma-separated)
Save Edits
Cancel