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 Quote 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 Quote 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. Quote 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. Quote 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 Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.