[php-src] Issue #13888: allow use class constant interpolation in strings

From: Date: Fri, 05 Apr 2024 09:33:59 +0000
Subject: [php-src] Issue #13888: allow use class constant interpolation in strings
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246707@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13888 Author: IVoyt ### Description For instance I have a class with public constant ``` class SomeClass { public const int STATUS_ACTIVE = 1; } ``` And I want to use the class constant in a string.Currently I have to use concatenation or assign the class constant's value to a variable and interpolate it in the string ``` // option 1 $query = QueryBuilder::where('status = ' . SomeClass::STATUS_ACTIVE); // option 2 $statusValue = SomeClass::STATUS_ACTIVE; $query = QueryBuilder::where("status = {$statusValue}"); ``` Would be cool and convenient to be able use interpolation for constants as well. ``` $query = QueryBuilder::where("status = {SomeClass::STATUS_ACTIVE}") ```

« previous php.bugs (#246707) next »