doulao3078 2015-05-03 20:06
浏览 21

将if语句添加到变量中

I am having trouble assigning my if statement to a variable. I am new to PHP, and I can't seem to assign my if statment. The varible keeps being displayed as empty. Have i written this wrong:

if ($url="http://test.co.uk") {
  $ifStmt == "strpos($link,'en/bruk/category') && strpos($link, 'store-locator')==false " .
       " && strpos($link, 'accessibility')==false && strpos($link, 'terms-conditions')==false  " .
       " && strpos($link, 'site-map')==false && strpos($link, 'write-a-review')==false " .
       " && strpos($link, 'press')==false && strpos($link, 'burton-menswear-apps')==false " .
       " && strpos($link, 'black-friday')==false && strpos($link, 'military-discount')==false " . 
       " && strpos($link, 'gift-card')==false && strpos($link, 'student-discount')==false " .
       " && strpos($link, 'formal-hire')==false && strpos($link, 'information-pages')==false " .
       " && strpos($link, 'responsibilities')==false && strpos($link, 'affiliates')==false " .
       " && strpos($link, 'featurearchive')==false";

}else{



$ifStmt == "strpos($link,'en/bruk/category') && strpos($link, 'evans-on-the-go')==false " .
       " && strpos($link, 'CatalogNavigationSearchResultCmd')==false && strpos($link, 'store-locator')==false " .
       " && strpos($link, 'LogonForm')==false && strpos($link, 'evans-card')==false " .
       " && strpos($link, 'delivery-landing-page')==false && strpos($link, 'accessibility')==false  " .
       " && strpos($link, 'newsletter-sign-up')==false && strpos($link, 'evans-on-the-go')==false " .
       " && strpos($link, 'evans-shape-hub')==false && strpos($link, 'new-lower-price')==false " .
       " && strpos($link, 'hpwk35')==false";


}
echo "if statement is ".$ifStmt;
  • 写回答

4条回答 默认 最新

  • duanlie7447 2015-05-03 20:08
    关注

    change your code to

     if ($url=="http://test.co.uk") {  
         $ifStmt = "strpos($link,
    

    need to use == in comparison and == for assignment

    you used assignment instead of == and used comparison instead of assignment.

    I hope you know the difference between == and ===

    评论

报告相同问题?