Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I receive this error Parse error: syntax error, unexpected T_DEFAULT in ../../functions.php on line 22

Here is functions.php section around line 22("default" specifically is line 22):

<?php
        break;
    default :
?>

It's default code from Wordpress' TwentyEleven functions.php, and unfortunately I'm still very much learning PHP so I'm not at all sure why the error is occurring. Any ideas?

ETA here is the full functions.php

if ( ! function_exists( 'twentyeleven_comment' ) ) :
/**
 * Template for comments and pingbacks.
 *
 * To override this walker in a child theme without modifying the comments template
 * simply create your own twentyeleven_comment(), and that function will be used instead.
 *
 * Used as a callback by wp_list_comments() for displaying the comments.
 *
 * @since Twenty Eleven 1.0
 */
function twentyeleven_comment( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment;
    switch ( $comment->comment_type ) :
        case 'pingback' :
        case 'trackback' :
    ?>
    <li class="post pingback">
        <p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
    <?php
            break;
        default :
    ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
        <article id="comment-<?php comment_ID(); ?>" class="comment">
            <footer class="comment-meta">
                <div class="comment-author vcard">
                    <?php
                        $avatar_size = 68;
                        if ( '0' != $comment->comment_parent )
                            $avatar_size = 39;

                        echo get_avatar( $comment, $avatar_size );

                        /* translators: 1: comment author, 2: date and time */
                        printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
                            sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
                            sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
                                esc_url( get_comment_link( $comment->comment_ID ) ),
                                get_comment_time( 'c' ),
                                /* translators: 1: date, 2: time */
                                sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
                            )
                        );
                    ?>

                    <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
                </div><!-- .comment-author .vcard -->

                <?php if ( $comment->comment_approved == '0' ) : ?>
                    <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
                    <br />
                <?php endif; ?>

            </footer>

            <div class="comment-content"><?php comment_text(); ?></div>

            <div class="reply">
                <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
            </div><!-- .reply -->
        </article><!-- #comment-## -->

    <?php
            break;
    endswitch;
}
endif; // ends check for twentyeleven_comment()
share|improve this question
2  
Where is the rest? – Neal Oct 16 '12 at 18:02
paste more code – GBD Oct 16 '12 at 18:02
This is not enough of the code for us to be able to determine the problem. Please post the entire switch statement. – JSK NS Oct 16 '12 at 18:03
I think PHP is just so confused that it doesn't know where to start. This is a fragment. – soulkphp Oct 16 '12 at 18:03
Looking at Wordpress's TwentyEleven functions.php, the specified code exists line on 526... nowhere near 22 – newfurniturey Oct 16 '12 at 18:06

3 Answers

Try to delete default:. And make sure that this line of code inside

switch(){

}
share|improve this answer
How do you even know that it is a switch statement? You know what happens when you "assume"? – Neal Oct 16 '12 at 18:05
Ok tell me when default word can be ? – kirugan Oct 16 '12 at 18:08

That seems to be part of the switch statement which usually take the following structure:

switch($aaa) {
    case 1:
        //do something
        break;
    case 2:
        //do something else
        break;
    case 3:
        ...
        ...
        ...
    default:
        /do something else again
        break;
 }

You can get all the info you need here http://php.net/manual/en/control-structures.switch.php

share|improve this answer

I made an oversight when copy/pasting the code; forgot the opening <?php and closing ?>.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.