简体   繁体   中英

if is_numeric condition issue

I have a http_build_query array and file_get_contents that looks like this:

 $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);

I need to check if $results returns a numeric value. If it does, I need to set a new variable ($lead_id) to equal $results, pass $lead_id through another http_build_query array and finally do another file_get_contents $results. The code above works fine. The second part of the code is where I need some assistance. This is what I have for the second part of my code:

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);

I think my problem is with the isset part of the code but I'm not sure.

you put

if (is_numberic($result)) {

should be

if (is_numeric($result)) {

But, i use this way

 if (ctype_digit($result)) {

that way it can only containt digits, no decimals or any other characters... not sure if thats what your after

You are calling $lead_id as a function. Just change

$lead_id(isset($results));

to

$lead_id = $results;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM