Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I didn't know that you could return a value from an include like that, that's incredibly handy (and makes me wonder why almost nobody does it that way).


I love this strategy, it's great for config. For example in the RocketSled microframework I mentioned earlier[1] you have a config file to instruct the system which class to execute by default in which you just put:

<?php return 'Hello World';

Being able to include a file like that in your project which returns a value has the advantage (in my opinion anyway) of not cluttering up the namespace with lots of defines(), of not requiring any magic naming convention, and of not having to call out to any external functions or edit config files that are part of the core system's version control.

[1]https://github.com/iaindooley/RocketSled




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: