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 Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/ 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 Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/#findComment-280530 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 Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/#findComment-280562 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 Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/#findComment-280570 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 Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/#findComment-280572 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. Link to comment https://forums.phpfreaks.com/topic/56789-maybe-a-dum-question/#findComment-280606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.