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. 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. 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. 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! 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
Archived
This topic is now archived and is closed to further replies.