PHP Inheritance: If A then Must Set B

SwedeHost

New Member
So, I tried to Google this but don't know what this kind of situation is called...I'm working on my first use of class inheritance, where a parent class defines a set of methods and then several other classes extend that parent.What I was wondering, is it possible to do something like this:\[code\]class foo { private bar = false; private baz = NULL;}\[/code\]Now let's say I have:\[code\]class foobar extends foo { }\[/code\]I'd like to be able to have a condition in "foo" that says if any class extends "foo" and sets "bar = true" then "baz" must be set (ie. not null), or else throw an exception.Is such a thing possible?
 
Back
Top