JonnySnip3r Posted April 5, 2011 Share Posted April 5, 2011 Hey guys when we make a class and you see: var myName; var myAddress; do we still need the var? or have they removed it? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/232744-whats-the-deal-with-var-in-classes/ Share on other sites More sharing options...
KevinM1 Posted April 5, 2011 Share Posted April 5, 2011 While the var keyword can still be used, it's a sign of PHP 4's OOP mechanism. Var gives a default visibility of public to the data member it's associated with. You're much better off providing the appropriate visibility modifier - public, protected, or private - depending on your needs. Quote Link to comment https://forums.phpfreaks.com/topic/232744-whats-the-deal-with-var-in-classes/#findComment-1197144 Share on other sites More sharing options...
JonnySnip3r Posted April 5, 2011 Author Share Posted April 5, 2011 Thanks dude, very helpful! Quote Link to comment https://forums.phpfreaks.com/topic/232744-whats-the-deal-with-var-in-classes/#findComment-1197151 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.