jackson.rich Posted September 10, 2007 Share Posted September 10, 2007 Hi guys, I couldn't find anything in the main PHP docs, but I was just wondering if I could get a quick clarifications between '.' (period or full stop) and '->' in accessing classes and objects. Mainly this is just for ease of coding for a database active records class. Thanks guys, I look forward to joining this great community more Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/ Share on other sites More sharing options...
redbullmarky Posted September 10, 2007 Share Posted September 10, 2007 the . is used to stick things together. generally it's just the :: and -> for accessing class methods and properties. $a = 'hello'; $b = 'world'; $c = $a . $b; // hello world $class = new MyClass(); $class->doSomething(); echo $class->variable; MyClass::doSomething(); // static method call Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-345308 Share on other sites More sharing options...
jackson.rich Posted September 10, 2007 Author Share Posted September 10, 2007 D'oh, I misinterpreted the error message. You are correct, you don't seem to be able to access objects through the period (as in C, which is where I went wrong). It's only for condensation. Thanks for the quick reply. Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-345316 Share on other sites More sharing options...
448191 Posted September 10, 2007 Share Posted September 10, 2007 I think you will have a hard time accessing objects in C at all. Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-345411 Share on other sites More sharing options...
adam_ Posted September 13, 2007 Share Posted September 13, 2007 lol...maybe jackson meant visual basic or something, i believe they use that convention Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-347705 Share on other sites More sharing options...
Gamic Posted September 16, 2007 Share Posted September 16, 2007 D'oh, I misinterpreted the error message. You are correct, you don't seem to be able to access objects through the period (as in C, which is where I went wrong). It's only for condensation. Thanks for the quick reply. I think you meant concatenation. Condensation is something entirely different Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-349477 Share on other sites More sharing options...
deadimp Posted September 16, 2007 Share Posted September 16, 2007 . is the string concatenation operator, as Gamic pointed out. It combines two strings into one. -> is the member-access operator, which accesses variables [methods] defined for an object. :: is the static access operator, for accessing statics (variables/functions) defined for a class. Link to comment https://forums.phpfreaks.com/topic/68693-quickie-difference-between-and-in-accessing-objects-and-classes/#findComment-349708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.