2012-03-15 53 views
0

我有一个http_build_query阵列的file_get_contents,看起来像这样:如果is_numeric条件问题

$optionValues = http_build_query(array( 
        'leadcomm' => getVariable('LEADCOMM'), 
        'CCID' => getVariable('CCID'), 
        'QTR' => getVariable('QTR'), 
        'CLK' => getVariable('CLK'), 
        'dck' => getVariable('DCK'), 
        'bal_one' => getVariable('BAL_ONE'), 
        'product' => getVariable('PRODUCT'), 
        'prop_st' => getVariable('PROP_ST'), 
        'cred_grade' => getVariable('CRED_GRADE'), 
        'prop_zip' => getVariable('PROP_ZIP'), 
        'prop_desc' => getVariable('PROP_DESC'), 
        'spec_home' => getVariable('SPEC_HOME'), 
        'purchase_contract' => getVariable('PURCHASE_CONTRACT'), 
        'est_val' => getVariable('EST_VAL'), 
        'down_pmt' => getVariable('DOWN_PMT'), 
        'loan_type' => getVariable('LOAN_TYPE'), 
        'buy_timeframe' => getVariable('BUY_TIMEFRAME'), 
        'agent_found' => getVariable('AGENT_FOUND'), 
        'va_status' => getVariable('VA_STATUS'), 
        'income' => getVariable('INCOME'), 
        'annual_verifiable_income' => getVariable('ANNUAL_VERIFIABLE_INCOME'), 
        'fha_bank_foreclosure' => getVariable('FHA_BANK_FORECLOSURE'), 
        'num_mortgage_lates' => getVariable('NUM_MORTGAGE_LATES'), 
        'email' => getVariable('EMAIL'), 
        'fname' => getVariable('FNAME'), 
        'lname' => getVariable('LNAME'), 
        'address' => getVariable('ADDRESS'), 
        'city' => getVariable('CITY'), 
        'state' => getVariable('STATE'), 
        'zip' => getVariable('ZIP'), 
        'pri_phon' => getVariable('PRI_PHON'), 
        'sec_phon' => getVariable('SEC_PHON'), 
        'capture_method' => getVariable('CAPTURE_METHOD'), 
        'aid' => getVariable('AID'), 
        'srlp' => getVariable('SRLP'), 
        'scid' => getVariable('SCID'), 
        'buyer_id' => getVariable('BUYER_ID'), 
        'cid' => getVariable('CID'), 
        'ppcid' => getVariable('PPCID') 
        ) 
       ); 


      $url = 'http://api.example.com/import-lead-data.php'; 
      $options['http'] = array(
          'method' => "POST", 
          'header' => 'Content-type: application/x-www-form-urlencoded', 
          'content' => $optionValues, 
          );  
      $context = stream_context_create($options);  
      $result = file_get_contents($url, NULL, $context); 

我需要检查,如果结果$返回一个数值。如果是这样,我需要设置一个新变量($ lead_id)等于$ results,将$ lead_id传递给另一个http_build_query数组,最后再做一个file_get_contents $结果。上面的代码工作正常。代码的第二部分是我需要一些帮助的地方。这是我的代码的第二部分:

if (is_numberic($result)) { 
       $lead_id(isset($results)); 
      }; 

$leadValues = http_build_query(array( 
        'lead_id' => "LEAD_ID" 
        ) 
       ); 

      $leadurl = 'http://api.bankradar.com/import-lead-response.php'; 
      $leadoptions['http'] = array(
          'method' => "POST", 
          'header' => 'Content-type: application/x-www-form-urlencoded', 
          'content' => $leadValues, 
          );  
      $leadcontext = stream_context_create($leadoptions);  
      $leadResult = file_get_contents($leadurl, NULL, $leadcontext); 

我认为我的问题是与代码的isset部分,但我不知道。

+0

'isset($ VAR)''返回值boolean' ...所以基本上你正在给'$ lead_id'分配'true' /'false'? (总是“真”) – 2012-03-15 14:33:52

+0

如果您关闭了错误,则代码将无提示失败,因为“is_numberic”不存在。这是什么意思:'$ lead_id(isset($ results));'?你真的试图调用一个名字存储在$ lead_id中的函数,哪个函数需要一个布尔值作为参数? – Leif 2012-03-15 14:36:06

+0

因此,而不是$ lead_id(isset($ results))$ lead_id == $结果会更有意义吗? – 2012-03-15 14:54:36

回答

1

你把

if (is_numberic($result)) { 

应该

if (is_numeric($result)) { 

但是,我用这种方式

if (ctype_digit($result)) { 

这样,它只能containt数字,没有小数或任何其他字符。 ..不知道如果那是什么你的后

0

您正在调用$ lead_id作为函数。只要改变

$lead_id(isset($results)); 

$lead_id = $results; 
0

你拼错is_numeric(有AB在你) - IS_NUM b埃里克

+0

感谢您发现错字 – 2012-03-15 14:55:14