Issue with my wordpress functions.php script
<p>Im having an issues when activating my theme in wordpress. I got this error message: </p>

<blockquote>
  <p>Parse error: syntax error, unexpected
  $end in
  C:\xampp\htdocs\xampp\wordpress\wp-content\themes\xit\functions.php
  on line 223</p>
</blockquote>

<p>Whats wrong, I totally dont understand. The script of the php is: </p>

<pre><code>&lt;?php if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' =&gt; '',
        'after_widget' =&gt; '',
        'before_title' =&gt; '&lt;h2&gt;',
        'after_title' =&gt; '&lt;/h2&gt;',
    ));

  function content($num) {  
  $theContent = get_the_content();  
  $output = preg_replace('/&lt;img[^&gt;]+./','', $theContent);  
  $limit = $num+1;  
  $content = explode(' ', $output, $limit);  
  array_pop($content);  
  $content = implode(" ",$content)."...";  
  echo $content;  
}

function post_is_in_descendant_category( $cats, $_post = null )
{
 foreach ( (array) $cats as $cat ) {
  // get_term_children() accepts integer ID only
  $descendants = get_term_children( (int) $cat, 'category');
  if ( $descendants &amp;&amp; in_category( $descendants, $_post ) )
   return true;
 }
 return false;
}

//custom comments

function mytheme_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?&gt;
   &lt;li &lt;?php comment_class(); ?&gt; id="li-comment-&lt;?php comment_ID() ?&gt;"&gt;


     &lt;div id="comment-&lt;?php comment_ID(); ?&gt;"&gt;
      &lt;div class="comment-author vcard"&gt;
   &lt;div class="comment-meta commentmetadata"&gt;
    &lt;?php echo get_avatar($comment,$size='32',$default='http://www.gravatar.com/avatar/61a58ec1c1fba116f8424035089b7c71?s=32&amp;d=&amp;r=G' ); ?&gt;
   &lt;?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?&gt; &lt;br /&gt;&lt;?php printf(__('&lt;strong&gt;%s&lt;/strong&gt; says:'), get_comment_author_link()) ?&gt;&lt;?php edit_comment_link(__('(Edit)'),'  ','') ?&gt;&lt;/div&gt;

      &lt;/div&gt;
      &lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;
         &lt;em&gt;&lt;?php _e('Your comment is awaiting moderation.') ?&gt;&lt;/em&gt;
         &lt;br /&gt;
      &lt;?php endif; ?&gt;

      &lt;div class="text"&gt;&lt;?php comment_text() ?&gt;&lt;/div&gt;

      &lt;div class="reply"&gt;
         &lt;?php comment_reply_link(array_merge( $args, array('depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))) ?&gt;
      &lt;/div&gt;
     &lt;/div&gt;
&lt;?php }
add_action('admin_menu', 'xit_theme_page');

function xit_theme_page ()
{
 if ( count($_POST) &gt; 0 &amp;&amp; isset($_POST['xit_settings']) )
 {
  $options = array ( 'style','logo_img','logo_alt','logo_txt', 'logo_tagline', 'tagline_width', 'contact_email','ads', 'advertise_page', 'twitter_link', 'facebook_link', 'flickr', 'about_tit', 'about_txt', 'analytics');

  foreach ( $options as $opt )
  {
   delete_option ( 'xit_'.$opt, $_POST[$opt] );
   add_option ( 'xit_'.$opt, $_POST[$opt] ); 
  }   


 }
 add_theme_page(__('Xit Options'), __('Xit Options'), 'edit_themes', basename(__FILE__), 'xit_settings'); 
}
function xit_settings ()
{?&gt;
&lt;div class="wrap"&gt;
 &lt;h2&gt;XIT Options Panel&lt;/h2&gt;

&lt;form method="post" action=""&gt;
 &lt;table class="form-table"&gt;
  &lt;!-- General settings --&gt;
  &lt;tr&gt;
   &lt;th colspan="2"&gt;&lt;strong&gt;General Settings&lt;/strong&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="style"&gt;Theme Color Scheme&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;select name="style" id="style"&gt;
     &lt;option value="pink.css" &lt;?php if(get_option('xit_style') == 'pink.css'){?&gt;selected="selected"&lt;?php }?&gt;&gt;pink.css&lt;/option&gt;
     &lt;option value="blue.css" &lt;?php if(get_option('xit_style') == 'blue.css'){?&gt;selected="selected"&lt;?php }?&gt;&gt;blue.css&lt;/option&gt;
     &lt;option value="orange.css" &lt;?php if(get_option('xit_style') == 'orange.css'){?&gt;selected="selected"&lt;?php }?&gt;&gt;orange.css&lt;/option&gt;

    &lt;/select&gt; 
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="logo_img"&gt;Logo image (full path to image)&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="logo_img" type="text" id="logo_img" value="&lt;?php echo get_option('xit_logo_img'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="logo_alt"&gt;Logo image ALT text&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="logo_alt" type="text" id="logo_alt" value="&lt;?php echo get_option('xit_logo_alt'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="logo_txt"&gt;Text logo&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="logo_txt" type="text" id="logo_txt" value="&lt;?php echo get_option('xit_logo_txt'); ?&gt;" class="regular-text" /&gt;
    &lt;br /&gt;&lt;em&gt;Leave this empty if you entered an image as logo&lt;/em&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="logo_tagline"&gt;Logo Tag Line&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="logo_tagline" type="text" id="logo_tagline" value="&lt;?php echo get_option('xit_logo_tagline'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="tagline_width"&gt;Tag Line Box Width (px)&lt;/label&gt;&lt;br /&gt;&lt;em style="font-size:11px"&gt;Default width: 300px&lt;/em&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="tagline_width" type="text" id="tagline_width" value="&lt;?php echo get_option('xit_tagline_width'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="contact_email"&gt;Email Address for Contact Form&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="contact_email" type="text" id="contact_email" value="&lt;?php echo get_option('xit_contact_email'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="twitter_link"&gt;Twitter link&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="twitter_link" type="text" id="twitter_link" value="&lt;?php echo get_option('xit_twitter_link'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="facebook_link"&gt;Facebook link&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="facebook_link" type="text" id="facebook_link" value="&lt;?php echo get_option('xit_facebook_link'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="flickr"&gt;Flickr Photostream&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;select name="flickr" id="flickr"&gt;
     &lt;option value="yes" &lt;?php if(get_option('xit_flickr') == 'yes'){?&gt;selected="selected"&lt;?php }?&gt;&gt;Yes&lt;/option&gt;
     &lt;option value="no" &lt;?php if(get_option('xit_flickr') == 'no'){?&gt;selected="selected"&lt;?php }?&gt;&gt;No&lt;/option&gt;
    &lt;/select&gt; 
    &lt;br /&gt;&lt;em&gt;Make sure you have FlickrRSS plugin activated if you choose to enable Flickr Photostream&lt;/em&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;!-- Sidebar ABout Box--&gt;
  &lt;tr&gt;
   &lt;th colspan="2"&gt;&lt;strong&gt;Sidebar About Box&lt;/strong&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="about_tit"&gt;Title&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;input name="about_tit" type="text" id="about_tit" value="&lt;?php echo get_option('xit_about_tit'); ?&gt;" class="regular-text" /&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="about_txt"&gt;Text&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;textarea cols="60" rows="5" name="about_txt" type="text" id="about_txt" class="regular-text" /&gt;&lt;?php echo get_option('xit_about_txt'); ?&gt;&lt;/textarea&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;!-- Ads Box Settings --&gt;
  &lt;tr&gt;
   &lt;th colspan="2"&gt;&lt;strong&gt;Ads Box Settings&lt;/strong&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;th&gt;&lt;label for="ads"&gt;Ads Section Enabled:&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;select name="ads" id="ads"&gt;
     &lt;option value="yes" &lt;?php if(get_option('xit_ads') == 'yes'){?&gt;selected="selected"&lt;?php }?&gt;&gt;Yes&lt;/option&gt;
     &lt;option value="no" &lt;?php if(get_option('xit_ads') == 'no'){?&gt;selected="selected"&lt;?php }?&gt;&gt;No&lt;/option&gt;
    &lt;/select&gt; 
    &lt;br /&gt;&lt;em&gt;Make sure you have AdMinister plugin activated and have the position "Sidebar" created within the plugin.&lt;/em&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign="top"&gt;
   &lt;th scope="row"&gt;&lt;label for="advertise_page"&gt;Advertise Page&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;?php wp_dropdown_pages("name=advertise_page&amp;show_option_none=".__('- Select -')."&amp;selected=" .get_option('xit_advertise_page')); ?&gt;
   &lt;/td&gt;
  &lt;/tr&gt;

  &lt;!-- Google Analytics --&gt;
  &lt;tr&gt;
   &lt;th&gt;&lt;label for="ads"&gt;Google Analytics code:&lt;/label&gt;&lt;/th&gt;
   &lt;td&gt;
    &lt;textarea name="analytics" id="analytics" rows="7" cols="70" style="font-size:11px;"&gt;&lt;?php echo stripslashes(get_option('xit_analytics')); ?&gt;&lt;/textarea&gt;
   &lt;/td&gt;
  &lt;/tr&gt;


 &lt;/table&gt;
 &lt;p class="submit"&gt;
  &lt;input type="submit" name="Submit" class="button-primary" value="Save Changes" /&gt;
  &lt;input type="hidden" name="xit_settings" value="save" style="display:none;" /&gt;
 &lt;/p&gt;
&lt;/form&gt;

&lt;/div&gt;
&lt;? }?&gt;
&lt;?php function get_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', $post-&gt;post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;


} ?&gt;
</code></pre>

<p>The last line is line 223.</p>
