多行变量中的函数

I'm trying to create af multi-line variable and echo out its contents. I have a couple of functions concatenated to the string and for some reason these get output before all of the other html.

/***SNIP***/
$reference[0] = '                       
        <div class="slide">
            <div class="reference-image">

            </div>
            <div class="reference-text">
                <h2 class="reference-title">' . the_title() . '</h2>
                <div class="reference-content">
                    ' . the_content() . '
                </div>
            </div>
        </div>
        ---
    ';

echo $reference[0];
/***SNIP***/

The html this outputs would be:

the_title
the_content
<div class="slide">
    <div class="reference-image">

    </div>
    <div class="reference-text">
        <h2 class="reference-title"></h2>
        <div class="reference-content">

        </div>
    </div>
</div>
---

Wordpress (somewhat annoyingly, in my opinion) doesn't return values from the_title() and the_content().

Instead, it echos (writes to the output stream) the value directly, which is why you can't concatinate it to your string. If you want to return the value instead, use the WP functions:

get_the_content()

and

get_the_title()