$variable and {variable}

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kenny
Forum Newbie
Posts: 12
Joined: Mon Jul 01, 2002 10:12 pm
Location: Florida

$variable and {variable}

Post by kenny »

I've seen this many times, yet I don't know how to do it. Can someone please explain how you can change

Code: Select all

$variable
to

Code: Select all

{variable}
?
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Simple: you can't.

The {} notation is used inside strings to denote a variable value. For example:

Code: Select all

$string = "cash";
$cashmoney = "{$string}money";
Also, the {} can denote a particular element of a string.

Code: Select all

$string{2}
will be the "s" in "cash" (you start from 0).

Is there a particular piece of code you're talking about?
User avatar
kenny
Forum Newbie
Posts: 12
Joined: Mon Jul 01, 2002 10:12 pm
Location: Florida

Post by kenny »

No code in particular. I was just wondering, because I've seen it a lot.
Post Reply