enridp Posted February 28, 2011 Share Posted February 28, 2011 Hi ! I'm a bit confused about how PHP access to our properties in an object. I've seen these two methods: $instance->something = 'nothing'; $instance->$something = 'nothing'; what is the difference between them? thanks !! enrique. Quote Link to comment https://forums.phpfreaks.com/topic/229130-what-is-the-difference-of-these-property-access-in-objects/ Share on other sites More sharing options...
trq Posted February 28, 2011 Share Posted February 28, 2011 The second one is not valid. Quote Link to comment https://forums.phpfreaks.com/topic/229130-what-is-the-difference-of-these-property-access-in-objects/#findComment-1180748 Share on other sites More sharing options...
PFMaBiSmAd Posted February 28, 2011 Share Posted February 28, 2011 Unless the variable $something contains the name of an actual property of the class. Quote Link to comment https://forums.phpfreaks.com/topic/229130-what-is-the-difference-of-these-property-access-in-objects/#findComment-1180754 Share on other sites More sharing options...
enridp Posted February 28, 2011 Author Share Posted February 28, 2011 Very clear, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/229130-what-is-the-difference-of-these-property-access-in-objects/#findComment-1180764 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.