src/XML/Util.php
function getXMLDeclaration($version = '1.0', $encoding = null, 
        $standalone = null)
    {
        $attributes = array(
            'version' => $version,
        );
        // add encoding
        if ($encoding !== null) {
            $attributes['encoding'] = $encoding;
        }
        // add standalone, if specified
        if ($standalone !== null) {
            $attributes['standalone'] = $standalone ? 'yes' : 'no';
        }

        return sprintf('<?xml%s?>', 
            XML_Util::attributesToString($attributes, false));
    }
function getXMLDeclaration($version = '1.0', $encoding = null, 
        $standalone = null)
    {
        $attributes = array(
            'version' => $version,
        );
        // add encoding
        if ($encoding !== null) {
            $attributes['encoding'] = $encoding;
        }
        // add standalone, if specified
        if ($standalone !== null) {
            $attributes['standalone'] = $standalone ? 'yes' : 'no';
        }

        return sprintf('<?xml%s?>', 
            XML_Util::attributesToString($attributes, false));
    }
build an xml declaration

<code>
require_once 'XML/Util.php';

// get an XML declaration:
$xmlDecl = XML_Util::getXMLDeclaration('1.0', 'UTF-8', true);
</code>

@param string $version    xml version
@param string $encoding   character encoding
@param bool   $standalone document is standalone (or not)

@return string xml declaration
@access public
@static
@uses attributesToString() to serialize the attributes of the XML declaration