${variable} syntax
Unless this is inside a double quote string, this is identical to $variable
Double-quoted string
In a double quoted string, you'd use this syntax where, for example, the variable name would otherwise be misinterpreted.
i.e. Here's some code echoing a variable named $variable
:
$variable = "something";
echo "This is a string with a $variable";
// outputs "This is a string with a something"
Here's the same code, but in this case the variable is immediately followed by the string "name":
echo "This is a string with a $variablename";
// outputs "This is a string with a "
In addition to the 'wrong' output, it'll throw an undefined variable error because $variablename
isn't defined.
Here's the same example, using curly braces to make explicit what is the variable:
$variable_name = "something";
echo "This is a string with a ${variable}name";
// outputs "This is a string with somethingname"
Template engines
From your edit:
<script id="productTemplate" type="text/x-jquery-tmpl">
<?php echo "Save:"; ?> ${savings} <?php echo "or"; ?> ${savings_percentage} <?php echo "%"; ?>
</script>
The variables here are not in php tags, so it's not logical to look for what they mean in a php-context. They are just plain text, and as indicated from the script tag - they are intended to be used with the (defunct) jquery tmpl function.
I need to add number_format to ${savings_percentage} so it can output:
Well, fix the js that you haven't put in the question so that it does that :)