Php 分析错误:语法错误,意外';其他';(T_ELSE)在Wordpress模板中
我正在对“解析错误:语法错误,意外的'else'”进行故障排除,我认为问题与我的括号有关。我是php新手,所以我不太清楚这里出了什么问题。这是一个wordpress页面模板,可以检查用户是否登录。。。如果没有,它将显示一条消息,说明您需要登录才能查看页面。下面是产生问题的.php模板的代码:Php 分析错误:语法错误,意外';其他';(T_ELSE)在Wordpress模板中,php,parsing,syntax,brackets,Php,Parsing,Syntax,Brackets,我正在对“解析错误:语法错误,意外的'else'”进行故障排除,我认为问题与我的括号有关。我是php新手,所以我不太清楚这里出了什么问题。这是一个wordpress页面模板,可以检查用户是否登录。。。如果没有,它将显示一条消息,说明您需要登录才能查看页面。下面是产生问题的.php模板的代码: <?php /* Template Name: Logged-In Users Page */ ?> <!--?php if(is_user_logged_in()):?--> &l
<?php
/*
Template Name: Logged-In Users Page
*/
?>
<!--?php if(is_user_logged_in()):?-->
<?php get_header(); ?>
<?php
$sidebar_position = get_post_meta( get_queried_object_id(), 'vw_page_sidebar_position', true );
$sidebar_position_class = '';
if ( 'left' == $sidebar_position ) {
$sidebar_position_class = 'sidebar-left';
} else if( 'right' == $sidebar_position ) {
$sidebar_position_class = 'sidebar-right';
} else {
$sidebar_position_class = 'sidebar-hidden';
}
?>
<div id="page-wrapper" class="container <?php echo $sidebar_position_class; ?>">
<div class="row">
<div id="page-content" class="col-sm-7 col-md-8">
<?php if (have_posts()) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'templates/page-title' ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?>>
<?php get_template_part( 'templates/post-formats/format', get_post_format() ); ?>
<div class="post-content"><?php the_content(); ?></div>
</article>
<?php endwhile; ?>
<?php get_template_part( 'templates/pagination' ); ?>
<?php comments_template(); ?>
<?php else : ?>
<h2><?php _e('Not Found', 'envirra') ?></h2>
<?php endif; ?>
</div>
<?php if ( 'left' == $sidebar_position || 'right' == $sidebar_position ) : ?>
<aside id="page-sidebar" class="sidebar-wrapper col-sm-5 col-md-4">
<?php get_sidebar(); ?>
</aside>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
<?php else:
wp_die('Sorry, you must first <a href="/wp-login.php">log in</a> to view this page. You can <a href="/wp-login.php?action=register">register free here</a>.');
endif; ?>
您已经注释掉了if语句的第一部分:
<!--?php if(is_user_logged_in()):?-->
应该是:
<?php if(is_user_logged_in()):?>
或者,删除结尾处的零件:
<?php else:
wp_die('Sorry, you must first <a href="/wp-login.php">log in</a> to view this page. You can <a href="/wp-login.php?action=register">register free here</a>.');
endif; ?>
哪一行?错误应该是
缺少开头等效项<代码>
-如果不使用它,请将其删除。而不是此