Q. Should I change my code back to using
dirname( __FILE__ ) instead of
A. No. I’m going to stick with
__DIR__ until someone complains.
I’ve been busy developing some plugin changes and started using
__DIR__ instead of
dirname( __FILE__ ).
Then I realized that
__DIR__ is a magic constant that was introduced in PHP 5.3…
and WordPress is still supported on PHP 5.2.
Yes, I could quite easily change the code back again.
- the new code I’m writing may be delivered using Composer, or be invoked using WP-CLI, both of which make PHP 5.3 a pre-requisite.
- I’m developing with PHP 5.5.
- All my hosting is PHP 5.3 or higher.
- SiteGround are moving to PHP 5.6
- PHP 5.3 is also out of support!
- PHP 5.5 has been out of active support since 10th July 2015!
- WordPress.org recommends PHP 5.4 or greater
So now I’ve set my minimum dependency on PHP 5.3, can I also start using Namespaces?