exec-PHP shows output at bottom of page

Create a shortcode and return the content instead of echoing it out so in your functions.php file add:

function myFunc($atts,$content = null) {
    while (ture) {
       return $content;
    }
    return '';
}

add_shortcode('myfunc','myFunc');

and in your page’s content instead of using exec-PHP just call your new shortcode:

[myfunc]val[/myfunc]