dhimok Posted June 22, 2007 Share Posted June 22, 2007 Hello, my question is. Where and when can I use { } to surround a variable? Like {$var} I know I can use it if echoing with echo "{$var}"; I was mostly wondering how I can use it on include pages if I use ob_get_contents Thanks Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 using those braces are not required in some reading ive done i found out that the braces on the variables makes the php read it fast and for some programmer ive ask they told me like it makes the code error free. but the explanation i accepted is that it makes the reading of variables fast. you can use those braces any time with your variables Quote Link to comment Share on other sites More sharing options...
Dragen Posted June 22, 2007 Share Posted June 22, 2007 I think it's generally better practice to output variables like this: echo 'this is a ' . $variable . '!'; instead of using brackets Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 22, 2007 Share Posted June 22, 2007 I'm with you on that oen dragen Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 ya using the {} makes a code more complicated but for some it realy help them any let them do waht they think it good for them Quote Link to comment Share on other sites More sharing options...
trq Posted June 23, 2007 Share Posted June 23, 2007 Its all personal opinion. Braces need only really be used when you are using complex variables (arrays) within a double quoted strings. Personally, id'e rather not use concatination, so I'm always using the {} curlys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.