简体   繁体   English

Wordpress-解析错误:语法错误,意外的“函数”(T_FUNCTION),期望的标识符(T_STRING)

[英]Wordpress - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING)

I have the following error with Wordpress using Woo-Commerce and Storefront theme. 使用Woo-Commerce和Storefront主题的Wordpress出现以下错误。

Error is - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) 错误是-解析错误:语法错误,意外的“函数”(T_FUNCTION),期望的标识符(T_STRING)

Can anyone help? 有人可以帮忙吗?

This is the standard code from the theme. 这是主题的标准代码。 No edits. 没有修改。 It just started to not work. 它只是开始不起作用。

Here is the function from line 31: 这是第31行的函数:

    <?php
if ( ! function_exists( 'storefront_display_comments' ) ) {

    function storefront_display_comments() {
        // If comments are open or we have at least one comment, load up the comment template.
        if ( comments_open() || '0' != get_comments_number() ) :
            comments_template();
        endif;
    }
}

if ( ! function_exists( 'storefront_comment' ) ) {

    function storefront_comment( $comment, $args, $depth ) {
        if ( 'div' == $args['style'] ) {
            $tag = 'div';
            $add_below = 'comment';
        } else {
            $tag = 'li';
            $add_below = 'div-comment';
        }
        ?>
        <<?php echo esc_attr( $tag ); ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
        <div class="comment-body">
        <div class="comment-meta commentmetadata">
            <div class="comment-author vcard">
            <?php echo get_avatar( $comment, 128 ); ?>
            <?php printf( wp_kses_post( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
            </div>
            <?php if ( '0' == $comment->comment_approved ) : ?>
                <em class="comment-awaiting-moderation"><?php esc_attr_e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
                <br />
            <?php endif; ?>

            <a href="<?php echo esc_url( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ); ?>" class="comment-date">
                <?php echo '<time datetime="' . get_comment_date( 'c' ) . '">' . get_comment_date() . '</time>'; ?>
            </a>
        </div>
        <?php if ( 'div' != $args['style'] ) : ?>
        <div id="div-comment-<?php comment_ID() ?>" class="comment-content">
        <?php endif; ?>
        <div class="comment-text">
        <?php comment_text(); ?>
        </div>
        <div class="reply">
        <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        <?php edit_comment_link( __( 'Edit', 'storefront' ), '  ', '' ); ?>
        </div>
        </div>
        <?php if ( 'div' != $args['style'] ) : ?>
        </div>
        <?php endif; ?>
    <?php
    }
}

Found out the answer myself. 自己找出答案。 Went into the file and removed a hr tag which was out of place and it fixed the issue. 进入文件并删除了不适当的hr标签,它解决了该问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP解析错误:语法错误,意外的T_STRING,预期的T_FUNCTION - PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION php解析错误:语法错误,意外的T_STRING,在构造上需要T_FUNCTION - php Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION on construct 解析错误:语法错误,意外\\&#39;?&gt; \\&#39;,期待函数(T_FUNCTION) - Parse error: syntax error, unexpected \'?>\', expecting function (T_FUNCTION) 激活了一个新的WP主题,并出现以下错误:解析错误:语法错误,意外的T_STRING,预期为T_OLD_FUNCTION或T_FUNCTION或T_VAR或&#39;}&#39; - Activated a new WP theme, getting this error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' ParseError:语法错误,意外的 'EntityManagerInterface' (T_STRING),期待 function (T_FUNCTION) 或 const (T_CONST) - ParseError: syntax error, unexpected 'EntityManagerInterface' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) 语法错误,意外的“请求”(T_STRING),期望 function (T_FUNCTION) 或 const (T_CONST) Laravel - syntax error, unexpected 'Request' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) Laravel 语法错误,意外的T_FUNCTION,预期为&#39;)&#39; - syntax error, unexpected T_FUNCTION, expecting ')' 错误:(!)分析错误:语法错误,意外的&#39;&#39;(T_ENCAPSED_AND_WHITESPACE),需要标识符(T_STRING) - Error : ( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) 解析错误:语法错误,意外的“;”,需要标识符(T_STRING)或变量(T_VARIABLE) - Parse error: syntax error, unexpected ';', expecting identifier (T_STRING) or variable (T_VARIABLE) Yii解析错误:语法错误,意外的&#39;if&#39;(T_IF),期望的函数(T_FUNCTION) - Yii Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM