NotionCommotion Posted July 22, 2016 Share Posted July 22, 2016 Let's say I just wanted to get the file extension from a path. I could use either http://php.net/manual/en/function.pathinfo.php or http://php.net/manual/en/splfileinfo.getextension.php. For this specific requirement, which one should I use. Generically, why would one chose one approach over the other? Quote Link to comment https://forums.phpfreaks.com/topic/301547-when-to-use-standard-functions-versus-spl-methods/ Share on other sites More sharing options...
Jacques1 Posted July 22, 2016 Share Posted July 22, 2016 The former is procedural, the latter is object-oriented. Choose whatever suits your application and personal preferences. Functionally, they're equivalent, which is why the manual always mentions both approaches. If you already rely heavily on object-orientation, it makes sense to go all the way. Otherwise use the classical PHP functions. 1 Quote Link to comment https://forums.phpfreaks.com/topic/301547-when-to-use-standard-functions-versus-spl-methods/#findComment-1534856 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.