setEscapeAmpersand() публичный Метод

If true, ampersands will be escaped as "\u0026". By default, ampersands are not escaped.
public setEscapeAmpersand ( boolean $enabled )
$enabled boolean Whether ampersands should be escaped
Пример #1
0
 public function testAmpersandNotEscaped()
 {
     $this->encoder->setEscapeAmpersand(false);
     $this->assertSame('"&"', $this->encoder->encode('&'));
 }
Пример #2
0
 public function __construct($path, $flags = 0)
 {
     Assert::string($path, 'The path must be a string. Got: %s');
     Assert::notEmpty($path, 'The path must not be empty.');
     Assert::integer($flags, 'The flags must be an integer. Got: %s');
     $this->path = $path;
     $this->flags = $flags;
     $this->encoder = new JsonEncoder();
     $this->encoder->setEscapeGtLt($this->flags & self::ESCAPE_GT_LT);
     $this->encoder->setEscapeAmpersand($this->flags & self::ESCAPE_AMPERSAND);
     $this->encoder->setEscapeSingleQuote($this->flags & self::ESCAPE_SINGLE_QUOTE);
     $this->encoder->setEscapeDoubleQuote($this->flags & self::ESCAPE_DOUBLE_QUOTE);
     $this->encoder->setEscapeSlash(!($this->flags & self::NO_ESCAPE_SLASH));
     $this->encoder->setEscapeUnicode(!($this->flags & self::NO_ESCAPE_UNICODE));
     $this->encoder->setPrettyPrinting($this->flags & self::PRETTY_PRINT);
     $this->encoder->setTerminateWithLineFeed($this->flags & self::TERMINATE_WITH_LINE_FEED);
     $this->decoder = new JsonDecoder();
     $this->decoder->setObjectDecoding(JsonDecoder::ASSOC_ARRAY);
 }