[SOLVED] Is there a way to get datatype long php?


Can I convert my int datatype variable to longint datatype because I need the object type to be long for soap API (XML)?


To convert PHP variables/arrays and object you can use SoapVar
to know further about SoapVar

for your task you need something like
$workOrder[‘ID’] = new SoapVar($data[‘ID’],XSD_LONG);

to convert PHP object into Soap Object follow the below code, hopefully it will help you in solving your problem

    $workOrder  = [];
    $workOrder['ID'] = new SoapVar($data['ID'],XSD_LONG);
    $note = [];
    $note['body'] = "valid note body";
    $note['date'] = new SoapVar("2022-07-18",XSD_DATETIME);
    $note['private'] = true;
    $note['subject'] = "valid note subject";

    $varNote = new SoapVar($note, SOAP_ENC_OBJECT, 'ns3:Note', null);
    $varWorkOrder = new SoapVar($workOrder, SOAP_ENC_OBJECT, 'ns3:WorkOrder', null);
       $response2 = $client->attachNoteToWorkOrder($varNote,$varWorkOrder);
    }catch (\SoapFault $exception){
        // dd($exception);


Answered By – Mudassir Ahmad

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published.