popcornplya Posted January 19, 2009 Share Posted January 19, 2009 I'm reading a book about OOP, the author puts "$str = "{$shopProduct->title}:", why the { } Also, is public and var the same thing for php 5+? Quote Link to comment Share on other sites More sharing options...
gevans Posted January 19, 2009 Share Posted January 19, 2009 The curly brackets are used to surround more 'complex' variables when setting them inline (not jumping out of a string) $str = "{$shopProduct->title}:"; //is the same as $str = $shopProduct->title.":"; //and on some servers it will work without the curly brackets $str = "$shopProduct->title:"; Using public and private denotes the availability of functions, methods and variables withing an object. var is still used so some examples; public var $foo = "bar"; private var $bar = "foo"; $foo can be directly accessed from outside of the object where $bar can only be accessed by the object iteslf. Quote Link to comment Share on other sites More sharing options...
popcornplya Posted January 19, 2009 Author Share Posted January 19, 2009 The curly brackets are used to surround more 'complex' variables when setting them inline (not jumping out of a string) $str = "{$shopProduct->title}:"; //is the same as $str = $shopProduct->title.":"; //and on some servers it will work without the curly brackets $str = "$shopProduct->title:"; Using public and private denotes the availability of functions, methods and variables withing an object. var is still used so some examples; public var $foo = "bar"; private var $bar = "foo"; $foo can be directly accessed from outside of the object where $bar can only be accessed by the object iteslf. Thanks a lot 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.