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+? Link to comment https://forums.phpfreaks.com/topic/141493-solved-2-questions/ 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. Link to comment https://forums.phpfreaks.com/topic/141493-solved-2-questions/#findComment-740615 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 Link to comment https://forums.phpfreaks.com/topic/141493-solved-2-questions/#findComment-740619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.