Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jlrdw's avatar
Level 75

PHP 8.2 deprecated general PHP question

I notice here: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation

They are talking about Variable variables which I have in another custom fromework. I get a data array for the view:

        if (!empty($data)) {
            foreach ($data as $variable => $value) {
                ${$variable} = $value;
            }
            unset($variable, $value);
        }

I know laravel uses extract which does the same.

However with setting error_reporting(E_ALL); All still works fine, no deprecated warnings. I admit I don't totally understand from the link when a deprecated warning will show. And their example are using quotation marks, I have none.

Does anyone make sense if what's in the link, and is my usage of Variable variables okay?

And another link ==========================

https://www.php.net/manual/en/migration82.deprecated.php

They have this list:

  • "self::method"
  • "parent::method"
  • "static::method"
  • ["self", "method"]
  • ["parent", "method"]
  • ["static", "method"]
  • ["Foo", "Bar::method"]
  • [new Foo, "Bar::method"]

I know laravel uses static::method as do I. Again I get no deprecated warnings. I also have places with self::method. So when would these usages cause a deprecated warning.

From what I read some of the people voting was confused. -- Thanks

0 likes
5 replies
webrobert's avatar

idk.. it seems pretty clear..

The "${var}" and "${expr}" style of string interpolation is deprecated. Use "$var"/"{$var}" and "{${expr}}", respectively.

?

webrobert's avatar
Level 51

these references are for string interpolation. Your example doesn't use string interpolation. Am I missing something?

 $deprecated =  "${string} interpolation?";
 $theNewSexy =  "{$string} interpolation?";
2 likes
jlrdw's avatar
Level 75

@webrobert in my case it's ${$variable} which is not even listed. Yet all situations were stated as listed in the 1 through 4. This is where I'm confused. My usage doesn't seem to be in the 1 - 4 cases. Yet all works as expected.

The link states:

These things caused confusion in the discussion, but will continue working as they are.

If the voters were confused, I am even more confused.

Like my static calls in the other section work with no warnings, What in the blank are they referring to.

I almost wish @taylorotwell or @jeffreyway would explain.

martinbean's avatar

@jlrdw But @webrobert is correct: it’s the braces around variables in double quoted strings that’s been deprecated; and not “variable variables” like in your example.

2 likes
jlrdw's avatar
Level 75

@martinbean thank you so much for answering and clearing that up. I'll give him BA.

Please or to participate in this conversation.