Hey i was looking through some of WP’s code and I noticed in certain cases between double quotes, they put curly brackets around the variable. Here is an example:
$templates[] = "header-{$name}.php";
I tried looking online, but found it difficult to search for this. Would anyone be able to explain the use of this / benefits?
Much appreciated.
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
Scroll way down to the part on variable parsing for a detailed explanation.
Basically, inside a double-quoted string, PHP with replace variables with their contents.
Wrapping the variable in curly braces allows you to access associative arrays, object members, functions, etc (
"{$var['key']} {$foo->bar} {${$foo->baz()}}"), and makes your code a little more readable (imho)