Rather than just writing a new function called import() i’d like to know if there’s a better solution. Otherwise require_once would be included in the scope of import() only, which is bad for any “global” variable there.
My import() function would work differently than require_once, but serves the same purpose (enhanced usability).
My gut instict opinion: Nah. Don’t do it.
A language has its native set of functions. Why introduce a proprietary function that has no added value.
I don’t think there is reason to be scared off by
require_once().I agree with you, using globals is not a great thing, but sacrificing the possibility of using them for a vanity function name is not a good way to go.
If paths are what you’re worried about, then why not write an
import()function that returns the correct path. Like so:the only – in my eyes not so horrible – downside is that you only have to make sure that import always returns a correct path to something, otherwise
require_oncewill crash. Other than that, it has the same comfort, allows you to control paths as you wish, but doesn’t cost you anything in terms of flexibility.