[lang-ref] ( here_document ) ( php )

<?php
	public function testHereDocument(): void
	{
		// <<<EOT ... EOT
		$s = <<<EOT
aaa
bbb
EOT;

		$this->assertSame("aaa\nbbb", $s);

		// backslacsh escape is enabled in heredoc
		$s_here = <<<EOT
aaa\nbbb
ccc
EOT;
		$this->assertEquals(3, count(explode("\n", $s_here)));

		// the quoted form is called nowdoc and disables backslash escapes
		$s_new = <<<'EOT'
aaa\nbbb
ccc
EOT;
		$this->assertEquals(2, count(explode("\n", $s_new)));
	}