note 129167 added to language.types.string
| From: | Donatmcr-incdotcom at main dot php dot net | Date: | Wed, 17 Jan 2024 15:39:44 +0000 |
| Subject: | note 129167 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221121@lists.php.net to get a copy of this message | ||
I've been in PHP for 25 years, I've always wanted to be able to use functions inside of {}
parsed strings.
It was only last week that I realized that it is there, always been there, the function variable.
$s = "I wanted to make a list of names: {implode(',', $names)}."; // DOES
NOT WORK.
But of course this is not recognized because it does not start with {$.
However, if by chance (or design) $implode were to be set to "implode";
then this would indeed work:
$implode = "implode";
. . .
$names = ['Bob','Ted','Alice'];
$s = "I wanted to make a list of names: {$implode(',', $names)}.";
Note this does only work for true functions, not language constructs.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 97.113.196.27)
----
Manual Page -- https://php.net/manual/en/language.types.string.php
Edit -- https://main.php.net/note/edit/129167
Del: integrated -- https://main.php.net/note/delete/129167/integrated
Del: useless -- https://main.php.net/note/delete/129167/useless
Del: bad code -- https://main.php.net/note/delete/129167/bad+code
Del: spam -- https://main.php.net/note/delete/129167/spam
Del: non-english -- https://main.php.net/note/delete/129167/non-english
Del: in docs -- https://main.php.net/note/delete/129167/in+docs
Del: other reasons-- https://main.php.net/note/delete/129167
Reject -- https://main.php.net/note/reject/129167
Search -- https://main.php.net/manage/user-notes.php