In general, if you are using PHP, performance should not be your biggest worry, write good looking code first (ie. readable and maintainable, self documenting etc.) then profile and optimize as needed. If you begin by worrying about speed, PHP is probably not the way to go.
But to answer your question... get_class has pretty decent performance, i think it's pretty well optimized inside the zend engine. trying to call a non-existing function and dealing with the error is much more expensive. (it is a fatal error to call a non existent function, you do not get to catch it unless you write a bunch of glue code in your base object)
Here's a bit of benchmarking to show some of the different methods of determining the ability to run a method.
benchmark.php:
<?php
class MyClass {
public function Hello() {
return 'Hello, World!';
}
}
function test_get_class( $instance ) {
$t = get_class( $instance );
}
function test_is_callable( $instance ) {
$t = is_callable( $instance, 'Hello' );
}
function test_method_exists( $instance ) {
$t = method_exists( $instance, 'Hello' );
}
function test_just_call( $instance ) {
$result = $instance->Hello();
}
function benchmark($iterations, $function, $args=null) {
$start = microtime(true);
for( $i = 0; $i < $iterations; $i ++ ) {
call_user_func_Array( $function, $args );
}
return microtime(true)-$start;
}
$instance = new MyClass();
printf( "get_class: %s\n", number_format(benchmark( 100000, 'test_get_class', array( $instance ) ), 5) );
printf( "is_callable: %s\n", number_format(benchmark( 100000, 'test_is_callable', array( $instance ) ), 5) );
printf( "method_exists: %s\n", number_format(benchmark( 100000, 'test_method_exists', array( $instance ) ), 5) );
printf( "just_call: %s\n", number_format(benchmark( 100000, 'test_just_call', array( $instance ) ), 5) );
?>
results:
get_class: 0.78946
is_callable: 0.87505
method_exists: 0.83352
just_call: 0.85176