在一个php include中显示certian div,在另一个php中显示所有div

我有一些内容存储在php文件中,我想在我的页面上包含两个地方.
首先,我想要包含所有内容,但在第二位,我只想在给定类的某些div中包含内容.

例如,我有以下文件:

index.php
content.php
list.php
problems.php

index.php具有以下内容:<?php include“list.php”;包括“problems.php”; ?取代. list.phpand problems.phpcontains< php include“content.php”; ?> content.phphave以下内容:

<div class="up">This location is up</div>
<div class="down">This location is down</div>

如何使用list.php显示content.php的所有内容,并且只在problems.php中显示div class =“down”的内容?

我试着补充一下

<style>
.up {display:none}
</style>

在problems.php中,但这从两个include中删除了所有div class =“up”.

谢谢!

解决方法

您可以使用id来区分

在problems.php中

<div id='problems'><php include "content.php"; ?></div>
<style>
   #problems .up {display:none}
</style>

相关文章

文章浏览阅读8.4k次,点赞8次,收藏7次。SourceCodester Onl...
文章浏览阅读3.4k次,点赞46次,收藏51次。本文为大家介绍在...
文章浏览阅读1.1k次。- php是最优秀, 最原生的模板语言, 替代...
文章浏览阅读1.1k次,点赞18次,收藏15次。整理K8s网络相关笔...
文章浏览阅读1.2k次,点赞22次,收藏19次。此网络模型提供了...
文章浏览阅读1.1k次,点赞14次,收藏19次。当我们谈论网络安...