XML_Serializer::setOption PHP Method

setOption() public method

You can use this method if you do not want to set all options in the constructor.
public setOption ( string $name, mixed $value ) : void
$name string option name
$value mixed option value
return void
    function setOption($name, $value)
    {
        $this->options[$name] = $value;
    }

Usage Example

 /**
  * Add encoding
  */
 public function testEncoding()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_XML_DECL_ENABLED, true);
     $s->setOption(XML_SERIALIZER_OPTION_XML_ENCODING, 'ISO-8859-1');
     $s->serialize('string');
     $this->assertEquals('<?xml version="1.0" encoding="ISO-8859-1"?><string>string</string>', $s->getSerializedData());
 }
All Usage Examples Of XML_Serializer::setOption