How to add a recent post function to a text widget I created for practice?

In the function widget( $args, $instance ), which generates the widget output, add the following code before the echo $after_widget; line:

// The Query
$the_query = new WP_Query( array( 'post_type' => 'page', 'posts_per_page' => '3' ) );

// The Loop
while ( $the_query->have_posts() ) :
    $the_query->the_post();
    echo '<li>' . get_the_title() . '</li>';
endwhile;

Additional information can be found on the WordPress Codex.

error code: 523