我有一個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部分,但我不知道。
'isset($ VAR)''返回值boolean' ...所以基本上你正在給'$ lead_id'分配'true' /'false'? (總是「真」) – 2012-03-15 14:33:52
如果您關閉了錯誤,則代碼將無提示失敗,因爲「is_numberic」不存在。這是什麼意思:'$ lead_id(isset($ results));'?你真的試圖調用一個名字存儲在$ lead_id中的函數,哪個函數需要一個布爾值作爲參數? – Leif 2012-03-15 14:36:06
因此,而不是$ lead_id(isset($ results))$ lead_id == $結果會更有意義嗎? – 2012-03-15 14:54:36