Custom filter not working

I believe your the simple nature of your example may have led to a misunderstanding of the way appy_filters() would operate. There is a great article that really explains how to use add_filter() and apply_filters() well, using very readable examples.

Basically, the problem appears to be that your code declares add_filter() AFTER you define it with add_filter(). This is an “order of operations” error.

Perhaps this annotated version can help:

// declare your filter function and callback .. usually pretty close to each other.
add_filter('ex1_append_text', 'callback_appender');
function callback_appender($initial_text){
    return $initial_text.' ... whatever ...';
}

// setup basic variable, as you did
$var="testing";
echo $var;

// apply the filters we declared above
$modified = apply_filters('ex1_append_text',$var);
echo $modified;