Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<SoapVarSoap\Sdl>
^SoapVarLast updated: Mon, 26 Oct 2026

SoapVar::__construct

(PHP 5, PHP 7, PHP 8)

SoapVar::__construct — SoapVar constructor

Description

public function SoapVar::__construct(
    mixed $data,
    ?int $encoding,
    ?string $typeName = null,
    ?string $typeNamespace = null,
    ?string $nodeName = null,
    ?string $nodeNamespace = null
)

Constructs a new SoapVar object.

Parameters

data

The data to pass or return.

encoding

The encoding ID, one of the XSD_... constants.

type_name

The type name.

type_namespace

The type namespace.

node_name

The XML node name.

node_namespace

The XML node namespace.

Changelog

Version Description
8.4.0 An instance of DateTimeInterface used as the value for an xsd:dateTime element, or a similar date and time type, is now serialized to its ISO 8601 representation, instead of being serialized as an empty string.
8.0.3 typeName, typeNamespace, nodeName,and nodeNamespace are nullable now.

Examples

Example #1 SoapVar::__construct() example

<?php
class SOAPStruct {
    function SOAPStruct($s, $i, $f)
    {
        $this->varString = $s;
        $this->varInt = $i;
        $this->varFloat = $f;
    }
}
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                     'uri'      => "http://test-uri/"));
$struct = new SOAPStruct('arg', 34, 325.325);
$soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd");
$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
?>

See Also


<SoapVarSoap\Sdl>
^SoapVarLast updated: Mon, 26 Oct 2026