我想通了。這將允許您使用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