-1
我正在使用簡單的html dom來嘗試在頁面上刮字,並在出現某些文本時更改按鈕。如何在PHP的頁面上刮字改變按鈕類型?
如果單詞「缺貨」出現在頁面上,我想反映一個不同的按鈕,如果這些單詞不出現。
我的代碼:
<?php
include 'includes/simple_html_dom.php';
$xeon5420 = file_get_html('www.wholesaleinternet.net/cart/?id=199');
?>
<?php foreach($xeon5420->find("out of stock") as $element);
if ($element == "out of stock) { echo <button
class="btn btn-danger">Out ofStock</button> };
if ($element != "out of stock")
{ echo <button class="btn btn-success">Order Now</button>};
?>
我得到的所有排序錯誤
編輯:
這是我現在,但仍收到錯誤:
<?php foreach($xeon5420->find("out of stock") as $element);
if ($element == "out of stock") { echo '<button class="btn btn-danger">Out of Stock</button>' };
if ($element != "out of stock") { echo '<button class="btn btn-success">Order Now</button>'};
?>
修復您的報價 –
您有分析器錯誤嘉豪。您需要在echo命令後面引用字符串。 –
_「我遇到了各種各樣的錯誤」_,_「這是我現在的但仍然在接受錯誤的方法」_ - 而且你仍然在做一個出色的工作,讓任何人都不知道這些錯誤實際上是什麼......聰明! – CBroe