I see this many times in code I look at.
What exactly is {variable} and how does it work in code? I see phrases that say "text text <a href="{URL"}>{LINK}</a>
How do you make this work?
| SitePoint Sponsor |
I see this many times in code I look at.
What exactly is {variable} and how does it work in code? I see phrases that say "text text <a href="{URL"}>{LINK}</a>
How do you make this work?

That's part of a templating system. The templating code parses the template looking for template variables like that and replaces them with the correct value. It's not part of the programming language but part of the application.
John Conde | Facebook | Twitter
Brainyminds Merchant Account Services I Love Code eBook Giant
Authorize.Net: AIM API | ARB API | CIM API Get the FREE code!
Merchant Accounts 101 | Ecommerce 101

the { } are also uses for in programming (php)...to include variable array elements and including inline code.
Pretty much its an easier way of not having to doPHP Code:$people = array("John","Jack","Joe");
foreach($people as $person){
echo "Hi, My Name is {$person}";
}
#This Will Output:
#Hi, My Name is John
#Hi, My Name is Jack
#Hi, My Name is Joe
#or
echo "Hi, My Name is {$people[0]}, My Friends are {$people[1]} and {$people[2]}";
#This will output:
#Hi My Name is John, My Friends are Jack and Joe ..
echo "Hi My Name is ".$person."!", makes your code cleaner too.
Kreative Development
Infinite Possibilities
oh sweet. Thank you very much! That makes sense when I see it in context like that.
Bookmarks