I found that you can bypass the name restriction for some reserved words in PHP 5.3 using the magic __call method.
public function __call( $name, $arguments ) { $fn = 'do_' . $name; if ( method_exists( $this, $fn ) ) { return call_user_func_array( array( $this, fn), $arguments ); } else { throw new Exception( 'Method "' . $name . '" does not exist.' ); } } protected function do_print( ) {
I'm not saying this is necessarily a good idea, but it allows you to make a call like $foo->print() .
I really see no reason why reserved words cannot be used as method names for classes. I could not come up with an ambiguous case that would have to be resolved.
source share