Home  >  Article  >  php教程  >  让PHP里包含PHP

让PHP里包含PHP

WBOY
WBOYOriginal
2016-06-06 20:08:391300browse

有这样一段代码,我能够在分类ID为9的时候,输出 Hello World ?php if ( is_category ( 9 )) { echo ' Hello World ' ; } ? 接下来,我希望在分类为9的时候,输出一段文章列表: ?php if ( is_category ( 9 )) { ? ?php $posts = get_posts ( ' showposts=15

有这样一段代码,我能够在分类ID为9的时候,输出 Hello World


if(is_category(9)){
    
echo'Hello World';
}
?>

接下来,我希望在分类为9的时候,输出一段文章列表:


if(is_category(9)){
?>
    
$posts = get_posts('showposts=15&cat=9'); ?>
    
if($posts) : ?>
    

    foreach($postsas$post) : setup_postdata($post); ?>
        
  • the_title(); ?>
        
    endforeach; ?>
        
        
    endif; ?>

    }
    ?>

    用好 { 以及 就行,笔记如上,以此备忘。

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn