I want to trigger a function based on a variable.
function sound_dog() { return \'woof\'; } function sound_cow() { return \'moo\'; } $animal = \'cow\'; print soun
You can do that, but not without interpolating the string first:
$animfunc = 'sound_' . $animal; print $animfunc();
Or, skip the temporary variable with call_user_func():
call_user_func('sound_' . $animal);