Skip to content

Escaped \${var} in Heredoc produces warning #15720

@mediaformat

Description

@mediaformat

Description

Within a Heredoc statement, the parser correctly escapes the \${url} used in the Template literal, treating it a string, but incorrectly, IMHO, emits a Warning:

Deprecated: Using ${var} in strings is deprecated, use {$var} instead.

The following code:

<?php
$script = <<<HTML
	<script>
		window.addEventListener("message", getFrames, false);
		function getFrames (e) {
			if (e.data.hasOwnProperty("url")) {
				let url = e.data.url.toString();
				let myFrame = document.querySelector(`iframe[src^='\${url}']`);
...

The actual output is correct

But I expected no Warning since I'm not using ${url} but \${url}

PHP Version

PHP 8.2.20

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions