我试图在输入y / n后使循环停止,但它只是返回打印并要求一个字符。这有什么不对?
代码:
<?php
while (have_posts()) : the_post();
get_template_part('template-parts/content', 'page');
do_action('flash_before_comment_template');
// If comments are open or we have at least one comment, load up the comment template.
if (comments_open() || get_comments_number()) :
comments_template();
endif;
do_action('flash_after_comment_template');
endwhile; // End of the loop.
?>
答案 0 :(得分:1)
注意你的状况;这两个条件中的一个始终为真,因此while条件始终为真。
将其更改为:
while (con != 'n' && con != 'y')