Home > php教程 > php手册 > 让PHP里包含PHP

让PHP里包含PHP

WBOY
Release: 2016-06-06 20:08:39
Original
1352 people have browsed it

有这样一段代码,我能够在分类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; ?>

    }
    ?>

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

    source:php.cn
    Statement of this Website
    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
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template