PHP strpos工作不正常

PHP strpos工作不正常,php,Php,为什么这个代码不起作用 output = {"Response":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w

为什么这个代码不起作用

  output = {"Response":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"><soap:Body><LeadEntryResponse xmlns=\"http:\/\/www.abc.com\/\"><LeadEntryResult><AFFILIATES_LEAD xmlns=\"\"><STATUS><LEAD_STATUS>REJECTED<\/LEAD_STATUS><REMARK> LEAD ALREADY EXSITS  - <\/REMARK><\/STATUS><\/AFFILIATES_LEAD><\/LeadEntryResult><\/LeadEntryResponse><\/soap:Body><\/soap:Envelope>"}
    key = LEAD ALREADY EXSITS
    //CODE
    if (strpos($output,$key) !== false)
     {

                         echo "success";
      } 
output={“Response”:“拒绝的潜在客户已经存在-”}
密钥=已存在潜在客户
//代码
if(strpos($output,$key)!==false)
{
呼应“成功”;
} 

来自数据库表的输出和键

它不起作用的第一个原因是变量应该有一个
$
前缀

第二,

key = LEAD ALREADY EXSITS
应该是

$key = "LEAD ALREADY EXSITS";

有几个原因导致此功能无法正常工作,缺少$,缺少引号和分号,以及JSON无法正确访问:

<?php
$output = '[{"Response":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"><soap:Body><LeadEntryResponse xmlns=\"http:\/\/www.abc.com\/\"><LeadEntryResult><AFFILIATES_LEAD xmlns=\"\"><STATUS><LEAD_STATUS>REJECTED<\/LEAD_STATUS><REMARK> LEAD ALREADY EXSITS  - <\/REMARK><\/STATUS><\/AFFILIATES_LEAD><\/LeadEntryResult><\/LeadEntryResponse><\/soap:Body><\/soap:Envelope>"}]';
$output = json_decode($output);
$key = "LEAD ALREADY EXSITS";
//CODE
if (strpos($output[0]->Response,$key) !== false) {
    echo "success";
}

显示it工作堆栈溢出驱动开发