2014-01-29 57 views
-1

我想在我的cmd值=比較時刪除這段代碼,我該怎麼做?如何在php中刪除html標籤?

這裏是我的代碼:

<h1 style="margin-top:24px;"><?=ucfirst($_GET['page5'])?><? if($_POST['mode']=='test' || $_GET['mode']=='test') { print " (Test Mode)"; } ?></h1> 

if($_GET['cmd']=='compare' && !$_POST) 
{ 
} 

我用這個代碼:

$dom = str_get_html($html); 

// ...or construct dom from file/url 
$dom = file_get_html($path); 

// strip h1 tags (and their content) 
foreach ($dom->find('h1') as $node) { 
$node->outertext = ''; 
} 

我如何刪除上面的代碼在CMD =由具有比較

回答

1

(如果我有很好的理解你的問題。) 我無法檢查的確切語法和PHP是不是我的主要語言,但是這件事情我已經做了我會像這樣寫

if($_GET['cmd']=='compare' && !$_POST) 
{ 
    [here comes the optional HTML code, may inclu php parts et] 
} 

因此,如果條件不符合,代碼將不會顯示。

0

你可以嘗試實現這一目標您的「測試模式」Cookie。 使用setCookie("name","value",time() + 60); 這將爲您的測試模式創建1分鐘長的cookie。

然後添加一個附加條件: if($_COOKIE['name']) { // CONTENT }