我想通了。这将允许您使用cushycms编辑您的PHP变量以包含页面。如果div id =“available”是除Yes之外的任何内容,page2.php将不会包含在page1.php中。代码附在下面。
page1.php中
<h1>This is Page1.php </h1>
<?php
// locate page you want to check div on - page2.php
$content = file_get_contents('page2.php');
// input your specific div id from - page2.php
$first_step = explode('<div id="available">' , $content);
$second_step = explode("</div>" , $first_step[1]);
// name your variable - in this case - $available
$available = trim($second_step[0]);
// input your output variable - $available and word to match in div - 'Yes'
if(false !== stripos($available, 'Yes')){
// if word in div=id'available' on page2.php is Yes - include page or echo
include 'page2.php';
}
?>
注:使page2.php,这和cushycms工作,你必须把DIV ID =“可用”的另一个DIV中有类或样式 - 参见下面的例子
使page2.php
<div id="wrapper" class="cushycms">
<div id="available">Yes</div>
</div>
<h2>Please include this rental into the page</h2>
'如果一个div包含单词YES'在哪里?在同一个PHP文件或字符串?这个div标签位于哪里? –
div是一个page1.php,如果page1.php上id =“available”的div包含单词YES,我想包含page2.php。 – AlwaysLearning
问题中的代码将全部位于同一页面上,page1.php – AlwaysLearning