PHP: enabled function against calling a static function. Better than the other?

I have a message class that I use like this:

RedirectMsg::go('somepage.php', MessageType::ERROR, 'Your message here.'); 

Would it be better to use a regular function? Or is this a personal problem?

 redirectMsg('somepage.php', MessageType::ERROR, 'Your message here.'); 
+4
source share
2 answers

Class objects help provide sudo pseudo-namespaces for functions so that they do not overlap, which can be very useful. A large number of functions in the global namespace are naming, expecting this to happen. If you are using PHP 5.3, you can look in namespaces .

+4
source

This is usually a personal preference. It also depends on the size of your application. You can allow yourself to "organize" less in a smaller application and just save yourself typing.

0
source

Source: https://habr.com/ru/post/1309278/


All Articles