Where to write a php function accesible to all my web app

Hello, I need to write a couple of functions accesible all over the web app. Where should I write this? And how do I access it then? Thanks.

You can create a Utils class that will have those functions in there and get it from there. For instance:

require 'library/Utils.php';

// Statically (personally I hate static calls)
$var1 = Utils::myFunc();
$var2 = Utils::yourFunc();

or you can register it in the DI container: ```php require 'library/Utils.php';

$di['utils'] = function () { return new Utils(); } ``` and then from a controller: ```php $var1 = $this->utils->myFunc(); $var2 = $this->utils->yourFunc(); ``` The above will not use statically defined functions.


Thanks Nicolaus :D