Should I use classes with static functions or namespaces to better organise a PHP project growing in size?
I come from a Java background and like having static variables/functions available.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The 2 features are completely different from each other.
The static keyword is to make a property or method available without an actual class instance.
http://php.net/manual/en/language.oop5.static.php
On the other hand Namespaces are for organization and avoiding naming collisions.
http://www.php.net/manual/en/language.namespaces.rationale.php