解析错误:语法错误,第13行的意外文件结束

use*_*454 -2 php syntax-error

我为我的代码保持错误" 解析错误:语法错误,第13行的文件意外结束 "...如下所示

<?php

    $all= get_posts(array('post_type' => 'books', 'numberposts' => -1,));

    foreach ( $all as $post ) :  setup_postdata($post);

        if (!empty($post))
        {
        $postid=$post->ID;
        echo $postid;
        }

    ?>
Run Code Online (Sandbox Code Playgroud)

Joh*_*nde 5

你忘了结束你的 foreach

<?php

$all= get_posts(array('post_type' => 'books', 'numberposts' => -1,));

foreach ( $all as $post ) :  setup_postdata($post);

    if (!empty($post))
    {
    $postid=$post->ID;
    echo $postid;
    }
 endforeach;
?>
Run Code Online (Sandbox Code Playgroud)