- str_replace: documentation ( source)
<?php
class Foo {
public function __get($var_name) {
return str_replace('_', ' ', $var_name);
}
}
$foo = new Foo();
if (empty($foo->haunting_ghost)) { // language construct
echo $foo->haunting_ghost;
}