PHP use a function in HereDoc

Heredocs are amazing ( under the right circumstances ), using ling strings with variables without endless echo’s or quotes and line endings. But using functions is a bit less convenient. I found the following made it work for me.

(example uses the wordpress translation function)

$tableHead = <<<TABLEHEAD
<table class="widefat" id="redirect-deleted-products-table">
    <thead>
        <tr>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
            <th>%s</th>
        </tr>
    </thead>
    <tbody>
TABLEHEAD;

printf(
    $tableHead,
    __('Old url', 'redirect-deleted-products'),
    __('ID', 'redirect-deleted-products'),
    __('Redirect to', 'redirect-deleted-products'),
    __('301 / 302 / non', 'redirect-deleted-products')
);