- substr: documentation ( source)
- strpos: documentation ( source)
<?php
class A {
public function __get($name) {
$pos = strpos($name, '#');
if ($pos !== false && $pos != 0 ) {
$func = substr($name, 0, $pos);
return $this->$func();
} else {
return $name;
}
}
private function f() {
return "f:a";
}
}
$a = new A();
echo $a->a;
$p = "f#a";
echo $a->$p;