Say I have a class
class person {
public static function get_pk(){
return self::$primary_key;
}
}
and an extended class
class user extends person {
protected $primary_key = 'id';
}
and I want to run:
echo user::get_pk(); // should echo id
Whenever I run this it fails naturally since $primary_key is not a static variable. How do I get it to return the primary key?
Yes, I can change the class structure, function structure and make it non-static, but for all intents and purposes assume the only thing we can change is the content of the static function get_pk
$primary_keyandget_pk()static inperson? That doesn't make a whole lot of sense if you ask me.